Page 1 of 2

Anti Recoil AHK for every Shooter

Posted: 17 Oct 2021, 07:20
by Yaruqii
Here I have an AHK with a GUI, which basicly drags down when you hold down the Left Mouse button, you can Also toggle it with a Hotkey, and you can also easily change the Speed of draging down, and you can change the Hotkey for toggling. The Function of draging down was coded by @Rohwedder, and the GUI was coded from @Smile_ and edited by me. I really Thank them both for the Help, and I hope you all have fun with this Script.

Code: Select all

Gui, Add, Text, xm ym+3, Hotkey:
Gui, Add, Hotkey, xm+40 ym vHotkeyC w240, % HotkeyCC := "End"
Hotkey, End, CheckBox
Gui, Add, Text, xm ym+33, Speed:
Gui, Add, Edit, xm+40 ym+30 vSpeed w240 ,1
Gui, Add, CheckBox, xm+200 ym+67 vED gCheckBox, Toggle Script
Gui, Add, Button, xm ym+60 w100, Apply Changes
Gui, Show, w300

Hotkey, LButton, LeftButton, Off
Hotkey, LButton Up, LeftButtonUp, Off
Return

GuiClose:
ExitApp

LeftButton:
    Gui, Submit, NoHide
    SendInput, {LButton Down}
    SetTimer, DragDown, % 10 / Speed
Return

LeftButtonUp:
    SendInput, {LButton Up}
    SetTimer, DragDown, Off
Return

DragDown:
    Gui, Submit, NoHide
    DllCall("mouse_event", "UInt", 0x01, "UInt", 0, "UInt", 1 + Speed)
Return

CheckBox:
    Gui, Submit, NoHide
    If (A_ThisHotkey = HotkeyCC)
        GuiControl,, ED, % !ED
    Gui, Submit, NoHide
    Stat := (ED) ? "On" : "Off"
    Hotkey, LButton, % Stat
    Hotkey, LButton Up, % Stat
Return

ButtonApplyChanges:
    Gui, Submit, NoHide
    If (HotkeyC != HotkeyCC) {
        Hotkey, % HotkeyCC, CheckBox, Off
        Hotkey, % HotkeyCC := HotkeyC, CheckBox, On
    }
Return

Re: Anti Recoil AHK for every Shooter

Posted: 28 Oct 2021, 02:17
by shitcake96
I'm extremely new to this. How do I adjust the speed at which it pulls the cursor down? Other than that, this script is amazing!

Re: Anti Recoil AHK for every Shooter

Posted: 28 Oct 2021, 08:11
by shitcake96
Never mind, I figured it out.

Re: Anti Recoil AHK for every Shooter

Posted: 03 Jul 2022, 06:08
by KrutzHJE
Hey, I really like this GUI and I know it has been a year but could you add a vertical (x) recoil as well. This is because some of the games I'm playing (e.g. Heroes and Generals) make the recoil goes a little bit diagonally to the right to "make it more realistic", Usually with a machine gun. Maybe you could add an x and y speed, idk I'm new to this AHK and still learning. It would help a lot if you do :D

Re: Anti Recoil AHK for every Shooter

Posted: 04 Jul 2022, 17:30
by Yaruqii
Ill try tomorrow

Re: Anti Recoil AHK for every Shooter

Posted: 15 Jul 2022, 08:25
by boggylol
Using decimals doesn't seem to work using this program. I've tried editing the speed value to be a float but it still doesn't work, any ideas?

Re: Anti Recoil AHK for every Shooter

Posted: 15 Jul 2022, 09:27
by joedf
this DllCall("mouse_event", "UInt", 0x01, "UInt", 0, "UInt", 1 + Speed) has UInt, so the result of 1+Speed will be changed to an unsigned integer.

Re: Anti Recoil AHK for every Shooter

Posted: 07 Dec 2022, 17:14
by thakyle
joedf wrote:
15 Jul 2022, 09:27
this DllCall("mouse_event", "UInt", 0x01, "UInt", 0, "UInt", 1 + Speed) has UInt, so the result of 1+Speed will be changed to an unsigned integer.
Was wondering if you could help me figure out why changing the code to this outputs an error that says the else has no if?

LeftButton:
if GetKeyState("Rbutton")
Gui, Submit, NoHide
SendInput, {LButton Down}
SetTimer, DragDown, % 10 / Speed
Else
Sleep 100
Return

Re: Anti Recoil AHK for every Shooter

Posted: 07 Dec 2022, 18:51
by boiler
Because only the line immediately following an "if" is conditional to it unless you group multiple lines into a code block with braces:

Code: Select all

LeftButton:
	if GetKeyState("Rbutton") {
		Gui, Submit, NoHide
		SendInput, {LButton Down}
		SetTimer, DragDown, % 10 / Speed
	}
	Else
		Sleep 100
Return

Re: Anti Recoil AHK for every Shooter

Posted: 08 Jan 2023, 03:30
by destro
can u guys add time duration of holding dragdown with a text bar
also when i hold ctrl it dont work

Re: Anti Recoil AHK for every Shooter

Posted: 08 Jan 2023, 04:10
by boiler
destro wrote: when i hold ctrl it dont work
Put a * in front of the hotkey label to have it work with different modifier keys.

Re: Anti Recoil AHK for every Shooter

Posted: 08 Jan 2023, 04:24
by destro
here ?

Code: Select all

*LeftButton:
    Gui, Submit, NoHide
    SendInput, {LButton Down}
    SetTimer, DragDown, % 10 / Speed
Return

Re: Anti Recoil AHK for every Shooter

Posted: 08 Jan 2023, 04:37
by boiler
No, in front of LButton this line:

Code: Select all

Hotkey, LButton, % Stat
and probably has to be carried through every other line that starts with Hotkey, LButton.

Re: Anti Recoil AHK for every Shooter

Posted: 08 Jan 2023, 04:54
by destro
Works, thanks !
Can u also add a text bar to write a number of duration (DragDown>Off)
I want to manipulate set timer > time in gui

Code: Select all

#NoEnv
	SendMode Input
	SetWorkingDir %A_ScriptDir%
	SetMouseDelay, -1
	SetKeyDelay, -1

MsgBox,, AHK ,Hello :)`nDelete = EXIT SCRIPT

Gui, Add, Text, xm ym+3, Start:
Gui, Add, Hotkey, xm+40 ym vHotkeyC w240, % HotkeyCC := "End"
Hotkey, End, CheckBox
Gui, Add, Text, xm ym+33, Speed:
Gui, Add, Edit, xm+40 ym+30 vSpeed w240 ,1
Gui, Add, CheckBox, xm+200 ym+67 vED gCheckBox, Active
Gui, Add, Button, xm ym+60 w100, Apply changes
Gui, Show, w300

Hotkey, *LButton, LeftButton, Off
Hotkey, *LButton Up, LeftButtonUp, Off
Return

GuiClose:
ExitApp

LeftButton:
    	Gui, Submit, NoHide
    	SendInput, {LButton Down}
    	SetTimer, DragDown, % 10 / Speed
	SetTimer, Time, 1000 / I want to manipulate time in gui
	Return

Time:
	SetTimer, DragDown, Off
	Return

LeftButtonUp:
    	SendInput, {LButton Up}
    	SetTimer, DragDown, Off
	Return

DragDown:
    	Gui, Submit, NoHide
    	DllCall("mouse_event", "UInt", 0x01, "UInt", 0, "UInt", 1 + Speed)
	Return

CheckBox:
    	Gui, Submit, NoHide
    	If (A_ThisHotkey = HotkeyCC)
        GuiControl,, ED, % !ED
    	Gui, Submit, NoHide
    	Stat := (ED) ? "On" : "Off"
    	Hotkey, *LButton, % Stat
    	Hotkey, *LButton Up, % Stat
	Return

ButtonApplyChanges:
    	Gui, Submit, NoHide
    	If (HotkeyC != HotkeyCC) {
        Hotkey, % HotkeyCC, CheckBox, Off
        Hotkey, % HotkeyCC := HotkeyC, CheckBox, On
    	}
	Return

~Delete::ExitApp

Re: Anti Recoil AHK for every Shooter

Posted: 08 Jan 2023, 07:49
by boiler
I guess you mean this:

Code: Select all

#NoEnv
	SendMode Input
	SetWorkingDir %A_ScriptDir%
	SetMouseDelay, -1
	SetKeyDelay, -1

MsgBox,, AHK ,Hello :)`nDelete = EXIT SCRIPT

Gui, Add, Text, xm ym+3, Start:
Gui, Add, Hotkey, xm+40 ym vHotkeyC w240, % HotkeyCC := "End"
Hotkey, End, CheckBox
Gui, Add, Text, xm ym+33, Speed:
Gui, Add, Edit, xm+40 ym+30 vSpeed w240 ,1
Gui, Add, Text, xm ym+63, Time:
Gui, Add, Edit, xm+40 ym+60 vTime w240 ,1000
Gui, Add, CheckBox, xm+200 ym+97 vED gCheckBox, Active
Gui, Add, Button, xm ym+90 w100, Apply changes
Gui, Show, w300

Hotkey, *LButton, LeftButton, Off
Hotkey, *LButton Up, LeftButtonUp, Off
Return

GuiClose:
ExitApp

LeftButton:
    	Gui, Submit, NoHide
    	SendInput, {LButton Down}
    	SetTimer, DragDown, % 10 / Speed
		SetTimer, Time, % Time
	Return

Time:
	SetTimer, DragDown, Off
	Return

LeftButtonUp:
    	SendInput, {LButton Up}
    	SetTimer, DragDown, Off
	Return

DragDown:
    	Gui, Submit, NoHide
    	DllCall("mouse_event", "UInt", 0x01, "UInt", 0, "UInt", 1 + Speed)
	Return

CheckBox:
    	Gui, Submit, NoHide
    	If (A_ThisHotkey = HotkeyCC)
        GuiControl,, ED, % !ED
    	Gui, Submit, NoHide
    	Stat := (ED) ? "On" : "Off"
    	Hotkey, *LButton, % Stat
    	Hotkey, *LButton Up, % Stat
	Return

ButtonApplyChanges:
    	Gui, Submit, NoHide
    	If (HotkeyC != HotkeyCC) {
        Hotkey, % HotkeyCC, CheckBox, Off
        Hotkey, % HotkeyCC := HotkeyC, CheckBox, On
    	}
	Return

~Delete::ExitApp

Re: Anti Recoil AHK for every Shooter

Posted: 08 Jan 2023, 19:44
by destro
thanks and i also added bar with delay settimer dragdown but it works only with [0] after 1.. it dont work like it should by my logic :/

Code: Select all

#NoEnv
	SendMode Input
	SetWorkingDir %A_ScriptDir%
	SetMouseDelay, -1
	SetKeyDelay, -1

Gui, Add, Text, xm ym+0, Start:
Gui, Add, Hotkey, xm+60 ym+0 vHotkeyC w120, % HotkeyCC := "End"
Hotkey, End, CheckBox

Gui, Add, Text, xm ym+30, Speed:
Gui, Add, Edit, xm+60 ym+30 vSpeed w120 ,1

Gui, Add, Text, xm ym+60, Duration:
Gui, Add, Edit, xm+60 ym+60 vDuration w120 ,500

Gui, Add, Text, xm ym+90, Delay:
Gui, Add, Edit, xm+60 ym+90 vDelay w120 ,0

Gui, Add, CheckBox, xm+190 ym+0 vED gCheckBox, Active
Gui, Add, Button, xm ym+120 w280, Apply changes

Gui, Add, Text, xm ym+150, I need delay works with 10/20/100...
Gui, Show, w300

Hotkey, *LButton, LeftButton, Off
Hotkey, *LButton Up, LeftButtonUp, Off
Return

GuiClose:
ExitApp


LeftButton:
    	Gui, Submit, NoHide
    	SendInput, {LButton Down}
	SetTimer, DragDown, % Delay
	SetTimer, Time, % Duration
	Return

Time:
	SetTimer, DragDown, Off
	Return

LeftButtonUp:
    	SendInput, {LButton Up}
    	SetTimer, DragDown, Off
	Return

DragDown:
    	Gui, Submit, NoHide
    	DllCall("mouse_event", "UInt", 0x01, "UInt", 0, "UInt", Speed)
	Return

CheckBox:
    	Gui, Submit, NoHide
    	If (A_ThisHotkey = HotkeyCC)
        GuiControl,, ED, % !ED
    	Gui, Submit, NoHide
    	Stat := (ED) ? "On" : "Off"
    	Hotkey, *LButton, % Stat
    	Hotkey, *LButton Up, % Stat
	Return

ButtonApplyChanges:
    	Gui, Submit, NoHide
    	If (HotkeyC != HotkeyCC) {
        Hotkey, % HotkeyCC, CheckBox, Off
        Hotkey, % HotkeyCC := HotkeyC, CheckBox, On
    	}
	Return

~Delete::ExitApp

Re: Anti Recoil AHK for every Shooter

Posted: 08 Jan 2023, 20:09
by boiler
Sorry. I don’t understand what you’re asking.

Re: Anti Recoil AHK for every Shooter

Posted: 09 Jan 2023, 06:44
by destro
in the window (delay) I wanted to delay the SetTimer, DragDown procedure, after clicking the left button by e.g. 100

Code: Select all

#NoEnv
	SendMode Input
	SetWorkingDir %A_ScriptDir%
	SetMouseDelay, -1
	SetKeyDelay, -1

Gui, Add, Text, xm ym+0, Start:
Gui, Add, Hotkey, xm+60 ym+0 vHotkeyC w120, % HotkeyCC := "End"
Hotkey, End, CheckBox

Gui, Add, Text, xm ym+30, Speed:
Gui, Add, Edit, xm+60 ym+30 vSpeed w120 ,1

Gui, Add, Text, xm ym+60, Duration:
Gui, Add, Edit, xm+60 ym+60 vDuration w120 ,500

Gui, Add, Text, xm ym+90, Delay:
Gui, Add, Edit, xm+60 ym+90 vDelay w120 ,0

Gui, Add, CheckBox, xm+190 ym+0 vED gCheckBox, Active
Gui, Add, Button, xm ym+120 w280, Apply changes

Gui, Add, Text, xm ym+150, I need delay works with 10/20/100...
Gui, Show, w300

Hotkey, *LButton, LeftButton, Off
Hotkey, *LButton Up, LeftButtonUp, Off
Return

GuiClose:
ExitApp


LeftButton:
    	Gui, Submit, NoHide
    	SendInput, {LButton Down}
	SetTimer, DragDown, % Delay
	SetTimer, Time, % -Duration
	Return

Time:
	SetTimer, DragDown, Off
	SoundBeep, 400
	Return

LeftButtonUp:
    	SendInput, {LButton Up}
    	SetTimer, DragDown, Off
	Return

DragDown:
    	Gui, Submit, NoHide
    	DllCall("mouse_event", "UInt", 0x01, "UInt", 0, "UInt", Speed)
	Return

CheckBox:
    	Gui, Submit, NoHide
    	If (A_ThisHotkey = HotkeyCC)
        GuiControl,, ED, % !ED
    	Gui, Submit, NoHide
    	Stat := (ED) ? "On" : "Off"
    	Hotkey, *LButton, % Stat
    	Hotkey, *LButton Up, % Stat
	Return

ButtonApplyChanges:
    	Gui, Submit, NoHide
    	If (HotkeyC != HotkeyCC) {
        Hotkey, % HotkeyCC, CheckBox, Off
        Hotkey, % HotkeyCC := HotkeyC, CheckBox, On
    	}
	Return

~Delete::ExitApp

Re: Anti Recoil AHK for every Shooter

Posted: 09 Jan 2023, 07:28
by boiler
I see you started a new thread asking that question and got replies, so I won’t reply here.

Re: Anti Recoil AHK for every Shooter

Posted: 09 Jan 2023, 17:21
by destro
can u help me there idk how to fight agains my settimer of delay cursor.