Anti Recoil AHK for every Shooter

Post gaming related scripts
Yaruqii
Posts: 31
Joined: 11 Jul 2021, 16:29

Anti Recoil AHK for every Shooter

Post by Yaruqii » 17 Oct 2021, 07:20

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

shitcake96
Posts: 8
Joined: 02 Mar 2021, 09:43

Re: Anti Recoil AHK for every Shooter

Post by shitcake96 » 28 Oct 2021, 02:17

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!

shitcake96
Posts: 8
Joined: 02 Mar 2021, 09:43

Re: Anti Recoil AHK for every Shooter

Post by shitcake96 » 28 Oct 2021, 08:11

Never mind, I figured it out.

KrutzHJE
Posts: 1
Joined: 03 Jul 2022, 05:56

Re: Anti Recoil AHK for every Shooter

Post by KrutzHJE » 03 Jul 2022, 06:08

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

Yaruqii
Posts: 31
Joined: 11 Jul 2021, 16:29

Re: Anti Recoil AHK for every Shooter

Post by Yaruqii » 04 Jul 2022, 17:30

Ill try tomorrow

boggylol
Posts: 1
Joined: 11 Jul 2022, 08:56

Re: Anti Recoil AHK for every Shooter

Post by boggylol » 15 Jul 2022, 08:25

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?

User avatar
joedf
Posts: 9117
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Anti Recoil AHK for every Shooter

Post by joedf » 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.
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]

thakyle
Posts: 4
Joined: 07 Dec 2022, 17:10

Re: Anti Recoil AHK for every Shooter

Post by thakyle » 07 Dec 2022, 17:14

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

User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Anti Recoil AHK for every Shooter

Post by boiler » 07 Dec 2022, 18:51

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

destro
Posts: 20
Joined: 08 Jan 2023, 02:40

Re: Anti Recoil AHK for every Shooter

Post by destro » 08 Jan 2023, 03:30

can u guys add time duration of holding dragdown with a text bar
also when i hold ctrl it dont work

User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Anti Recoil AHK for every Shooter

Post by boiler » 08 Jan 2023, 04:10

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.

destro
Posts: 20
Joined: 08 Jan 2023, 02:40

Re: Anti Recoil AHK for every Shooter

Post by destro » 08 Jan 2023, 04:24

here ?

Code: Select all

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

User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Anti Recoil AHK for every Shooter

Post by boiler » 08 Jan 2023, 04:37

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.

destro
Posts: 20
Joined: 08 Jan 2023, 02:40

Re: Anti Recoil AHK for every Shooter

Post by destro » 08 Jan 2023, 04:54

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

User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Anti Recoil AHK for every Shooter

Post by boiler » 08 Jan 2023, 07:49

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

destro
Posts: 20
Joined: 08 Jan 2023, 02:40

Re: Anti Recoil AHK for every Shooter

Post by destro » 08 Jan 2023, 19:44

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

User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Anti Recoil AHK for every Shooter

Post by boiler » 08 Jan 2023, 20:09

Sorry. I don’t understand what you’re asking.

destro
Posts: 20
Joined: 08 Jan 2023, 02:40

Re: Anti Recoil AHK for every Shooter

Post by destro » 09 Jan 2023, 06:44

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

User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Anti Recoil AHK for every Shooter

Post by boiler » 09 Jan 2023, 07:28

I see you started a new thread asking that question and got replies, so I won’t reply here.

destro
Posts: 20
Joined: 08 Jan 2023, 02:40

Re: Anti Recoil AHK for every Shooter

Post by destro » 09 Jan 2023, 17:21

can u help me there idk how to fight agains my settimer of delay cursor.

Post Reply

Return to “Gaming Scripts (v1)”