INSTRUCTIONS:
Just copy the following code at the top of your scripts:
and replace your Sleep commands with this:
EXPLANATION:
Video games in particular may require high precision inputs. The above optimizations are aimed at making your AutoHotkey scripts more accurate, I will now describe why:
The default sleep command used by AutoHotkey has limited precision:
- sleeping below 10 or 15 milliseconds is not possible
- whatever number you use will not be precise (your script may sleep less or more than the value you've set)
Some default settings will also add more sleep time:
- default SetBatchLines makes your script sleep 10 milliseconds every line!
- default SendEvent is slower than SendInput
- in case SendEvent must be used, various parameters such as SetKeyDelay, SetMouseDelay and SetDefaultMouseSpeed will all add delays
- depending on your script, optimizing SetWinDelay and SetControlDelay may help too
There are other ways to slightly reduce the CPU load and increase process priority too:
- disabling environment variables
- disabling key history
- changing process priority to High
Other useful code is included too:
- the two "Interval" commands exist to make fast key presses work smoothly with no popup interruption
- auto-detect if the script is running as Administrator or not
- adding $* before an hotkey will ensure it works correctly in most of the games
Additional information from the official AutoHotkey forums can be found here (such as testable benchmarks and PixelSearch "Fast" parameter being slower than default if you only search for 1 pixel of 1 color): autohotkey.com/boards/viewtopic.php?f=6&t=6413
EXAMPLE:
This is a working optimized "Instant WallJump" macro designed for S4 League. You can save it as as ANYTHING.AHK to give it a try.
Hold LEFT ALT to mash SPACEBAR every ingame frame. Because S4 runs at 62.5 FPS... 1000 milliseconds ÷ 62,5 frames = 16 milliseconds to sleep (+ 0,1 since it's always good to add some leniency).
Press INS to enable/disable the script.
WARNING:
Using the alternative sleep I posted will conflict with SetTimer if you're using such command.
If you're running a loop with these optimizations, ALWAYS sleep somewhere, otherwise your script would send keys too fast for your computer to handle.
Just copy the following code at the top of your scripts:
Code:
#NoEnv #MaxHotkeysPerInterval 99000000 #HotkeyInterval 99000000 #KeyHistory 0 ListLines Off Process, Priority, , H SetBatchLines, -1 SetKeyDelay, -1, -1 SetMouseDelay, -1 SetDefaultMouseSpeed, 0 SetWinDelay, -1 SetControlDelay, -1 SendMode Input
Code:
DllCall("Sleep","UInt",INSERT_MILLISECONDS_HERE)
EXPLANATION:
Video games in particular may require high precision inputs. The above optimizations are aimed at making your AutoHotkey scripts more accurate, I will now describe why:
The default sleep command used by AutoHotkey has limited precision:
- sleeping below 10 or 15 milliseconds is not possible
- whatever number you use will not be precise (your script may sleep less or more than the value you've set)
Some default settings will also add more sleep time:
- default SetBatchLines makes your script sleep 10 milliseconds every line!
- default SendEvent is slower than SendInput
- in case SendEvent must be used, various parameters such as SetKeyDelay, SetMouseDelay and SetDefaultMouseSpeed will all add delays
- depending on your script, optimizing SetWinDelay and SetControlDelay may help too
There are other ways to slightly reduce the CPU load and increase process priority too:
- disabling environment variables
- disabling key history
- changing process priority to High
Other useful code is included too:
- the two "Interval" commands exist to make fast key presses work smoothly with no popup interruption
- auto-detect if the script is running as Administrator or not
- adding $* before an hotkey will ensure it works correctly in most of the games
Additional information from the official AutoHotkey forums can be found here (such as testable benchmarks and PixelSearch "Fast" parameter being slower than default if you only search for 1 pixel of 1 color): autohotkey.com/boards/viewtopic.php?f=6&t=6413
EXAMPLE:
This is a working optimized "Instant WallJump" macro designed for S4 League. You can save it as as ANYTHING.AHK to give it a try.
Hold LEFT ALT to mash SPACEBAR every ingame frame. Because S4 runs at 62.5 FPS... 1000 milliseconds ÷ 62,5 frames = 16 milliseconds to sleep (+ 0,1 since it's always good to add some leniency).
Press INS to enable/disable the script.
Code:
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , H
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
$*LAlt::
Loop
{
if not GetKeyState("LAlt","P")
break
Send {Space Down}
DllCall("Sleep","UInt",16.1)
Send {Space Up}
DllCall("Sleep","UInt",16.1)
}
return
$*Ins::Suspend
WARNING:
Using the alternative sleep I posted will conflict with SetTimer if you're using such command.
If you're running a loop with these optimizations, ALWAYS sleep somewhere, otherwise your script would send keys too fast for your computer to handle.