Register for your free account! | Forgot your password?

Go Back   elitepvpers > Shooter > S4 League
You last visited: Today at 11:21

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[GUIDE] Optimize AutoHotkey timing

Discussion on [GUIDE] Optimize AutoHotkey timing within the S4 League forum part of the Shooter category.

Reply
 
Old   #1
 
WAZAAAAA...'s Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 91
Received Thanks: 81
Post [GUIDE] Optimize AutoHotkey timing

INSTRUCTIONS:
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
and replace your Sleep commands with this:
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.
WAZAAAAA... is offline  
Thanks
2 Users
Old 03/26/2016, 01:11   #2
 
elite*gold: 0
Join Date: Apr 2011
Posts: 147
Received Thanks: 5
thanks dude its really useful

Edit: if i need to set my macro to 13 milliseconds i have to change 16.1 to 13.1? just like this ?
DllCall("kernel32.dll\Sleep", "UInt", 13.1)
ahmed1234550 is offline  
Old 03/26/2016, 05:17   #3
 
WAZAAAAA...'s Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 91
Received Thanks: 81
Quote:
Originally Posted by ahmed1234550 View Post
thanks dude its really useful

Edit: if i need to set my macro to 13 milliseconds i have to change 16.1 to 13.1? just like this ?
DllCall("kernel32.dll\Sleep", "UInt", 13.1)
If you want to sleep for 13 ms just put 13. If you have a game that runs at 77 FPS, I guess that 13.1 would be better.

The 16.1 is there because an ingame frame lasts 16 milliseconds, so adding that +0.1 ensures that S4 will NOT skip your input. For example, if I made the example script sleep for 8 instead of 16.1, half of the inputs would be ignored by the game because they happen too fast, and the macro would be terrible.

Maybe if you play a random game in slow motion frame by frame, you would understand what I'm trying to say better... but you can always try. Cheat Engine speedhack at 0.02, you will have to hold buttons for a lot of time to let the game register them, more specifically until the NEXT FRAME.
WAZAAAAA... is offline  
Old 03/27/2016, 12:47   #4
 
elite*gold: 0
Join Date: Dec 2011
Posts: 198
Received Thanks: 23
Could you help me making a bot that can be able to stun stabs like speedcounter against dash?Only problem is the delay.
GalaxyCMS123 is offline  
Old 03/27/2016, 17:45   #5
 
elite*gold: 0
Join Date: Apr 2011
Posts: 147
Received Thanks: 5
can you share your dash cancel code plz ? or just make one for me :c
ahmed1234550 is offline  
Old 03/28/2016, 08:28   #6
 
WAZAAAAA...'s Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 91
Received Thanks: 81
Quote:
Originally Posted by GalaxyCMS123 View Post
Could you help me making a bot that can be able to stun stabs like speedcounter against dash?Only problem is the delay.
Even with perfect execution, it's not really possible to SpeedCounter very fast combos such as Spy Dagger or Plasma Sword Dashes, because you have to take into account the LAG. Maybe you could pull it off in an offline/LAN situation, lol.
But still, here's a macro I made a while ago if you want to try:
Works best with a Counter Sword or Twin Blade (on slot 2) because they have the fastest SpeedCounters on left click ( ).
F = executes SpeedCounter
Ins = enable/disable
Code:
#InstallMouseHook
#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
if not A_IsAdmin
{
	MsgBox, You are running this script with no administrator rights. It may not work.
}

$*f::
;ensuring that the player doesn't interfere with the macro
Send {SC011 Up} ;W
Send {SC01E Up} ;A
Send {SC01F Up} ;S
Send {SC020 Up} ;D
Send {Click Right Up}
;the actual inputs
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {Space Up}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {SC020 Down}
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {Space Up}
Send {SC020 Up}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {2 Down}
Send {Click Left Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {Click Left Up}
Send {2 Up}
;ensuring that the macro doesn't interfere with the player
if GetKeyState("SC011","P")
	Send {SC011 Down}
if GetKeyState("SC01E","P")
	Send {SC01E Down}
if GetKeyState("SC01F","P")
	Send {SC01F Down}
if GetKeyState("SC020","P")
	Send {SC020 Down}
if GetKeyState("RButton","P")
	Send {Click Right Down}
return

$*Ins::Suspend
Quote:
Originally Posted by ahmed1234550 View Post
can you share your dash cancel code plz ? or just make one for me :c
What does "dash cancel" mean? Be more specific.
WAZAAAAA... is offline  
Old 03/28/2016, 10:01   #7
 
elite*gold: 0
Join Date: Dec 2011
Posts: 198
Received Thanks: 23
Quote:
Originally Posted by WAZAAAAA... View Post
Even with perfect execution, it's not really possible to SpeedCounter very fast combos such as Spy Dagger or Plasma Sword Dashes, because you have to take into account the LAG. Maybe you could pull it off in an offline/LAN situation, lol.
But still, here's a macro I made a while ago if you want to try:
Works best with a Counter Sword or Twin Blade (on slot 2) because they have the fastest SpeedCounters on left click ( ).
F = executes SpeedCounter
Ins = enable/disable
Code:
#InstallMouseHook
#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
if not A_IsAdmin
{
	MsgBox, You are running this script with no administrator rights. It may not work.
}

$*f::
;ensuring that the player doesn't interfere with the macro
Send {SC011 Up} ;W
Send {SC01E Up} ;A
Send {SC01F Up} ;S
Send {SC020 Up} ;D
Send {Click Right Up}
;the actual inputs
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {Space Up}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {SC020 Down}
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {Space Up}
Send {SC020 Up}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {2 Down}
Send {Click Left Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.1)
Send {Click Left Up}
Send {2 Up}
;ensuring that the macro doesn't interfere with the player
if GetKeyState("SC011","P")
	Send {SC011 Down}
if GetKeyState("SC01E","P")
	Send {SC01E Down}
if GetKeyState("SC01F","P")
	Send {SC01F Down}
if GetKeyState("SC020","P")
	Send {SC020 Down}
if GetKeyState("RButton","P")
	Send {Click Right Down}
return

$*Ins::Suspend
What does "dash cancel" mean? Be more specific.
Don't you think would be better "s" instead of "d" because when you hold it with sp it dodges instead of speeding it, so it would work only when you are without sp and stunned, or i'm wrong?@WAZAAAAA...
PS: are you italian?
GalaxyCMS123 is offline  
Old 03/28/2016, 10:08   #8
 
WAZAAAAA...'s Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 91
Received Thanks: 81
Quote:
Originally Posted by GalaxyCMS123 View Post
Don't you think would be better "s" instead of "d" because when you hold it with sp it dodges instead of speeding it, so it would work only when you are without sp and stunned, or i'm wrong?@WAZAAAAA...
PS: are you italian?
sė lo sono e non ho capito una sega di quel che hai scritto
In uno SpeedCounter serve sempre l'input di un Dodge (A o D + Spazio), sia con SP che senza. Forse ti riferisci a qualcos'altro tu.
WAZAAAAA... is offline  
Old 03/28/2016, 14:45   #9
 
elite*gold: 0
Join Date: Apr 2011
Posts: 147
Received Thanks: 5
if someone hit me with ps, dash i cancel it and change my weapon and block it with cs also dagger cancel, you know what i mean?
sorry for my english
ahmed1234550 is offline  
Old 03/29/2016, 12:17   #10
 
WAZAAAAA...'s Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 91
Received Thanks: 81
Quote:
Originally Posted by ahmed1234550 View Post
if someone hit me with ps, dash i cancel it and change my weapon and block it with cs also dagger cancel, you know what i mean? like this video
sorry for my english

Quote:
Originally Posted by GalaxyCMS123 View Post
Could you help me making a bot that can be able to stun stabs like speedcounter against dash?Only problem is the delay.
Guys, this thread was supposed to help you build your own macros more efficiently, yet you're asking me to do all that shit for you...

...k

Here's my optimized SpeedCounter with Revenge (or "dash cancel" according to ahmed1234550 lol) that you've been asking for. The best part about it is that it has no "requirement": there's no need to change weapon, click anything, or release WASD directions. The macro should handle everything automatically.
For example, you can physically hold S+D+RightClick, while equipping a Submachine Gun, and the macro would STILL correctly switch to CS and input the Revenge SpeedCounter.
COMMANDS:
Mouse wheel (no need to hold it) = SpeedCounter
Ins = script ON/OFF
Code:
#InstallMouseHook
#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
if not A_IsAdmin
{
	MsgBox, You are running this script with no administrator rights. It may not work.
}

$*MButton::
;ensuring that the player doesn't interfere with the macro
Send {SC011 Up} ;W
Send {SC01E Up} ;A
Send {SC01F Up} ;S
Send {SC020 Up} ;D
;the actual inputs
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.5)
Send {2 Down}
Send {Click Right Down}
Send {Space Up}
DllCall("kernel32.dll\Sleep", "UInt", 16.5)
Send {2 Up}
Send {SC020 Down}
Send {Space Down}
DllCall("kernel32.dll\Sleep", "UInt", 16.5)
Send {Space Up}
Send {SC020 Up}
;ensuring that the macro doesn't interfere with the player
if GetKeyState("SC011","P")
	Send {SC011 Down}
if GetKeyState("SC01E","P")
	Send {SC01E Down}
if GetKeyState("SC01F","P")
	Send {SC01F Down}
if GetKeyState("SC020","P")
	Send {SC020 Down}
DllCall("kernel32.dll\Sleep", "UInt", 350)
if GetKeyState("RButton","P")
	Send {Click Right Down}
else
	Send {Click Right Up}
return

$*Ins::Suspend
WARNING: you will most likely fail at SpeedCountering Dash attacks unless the attacker has very low ping to you, because they are too fast. CS needs to be on slot 2.

If you know about a better approach, let me know.
WAZAAAAA... is offline  
Thanks
2 Users
Old 03/30/2016, 00:57   #11
 
elite*gold: 0
Join Date: Apr 2011
Posts: 147
Received Thanks: 5
this code works better for me and i tried it, works fine with dash cancel and dagger cancel but little slow
ur code more faster but sometimes bot ignore my click
check this code if u can edit something to make it better
PHP Code:
3 downcs
16.1
3 up
cs
16.1
S down
16.1
SPACE down
16.1
S up
16.1
SPACE up
16.1
D down
16.1
SPACE down
16.1
D up
16.1
SPACE up
RButton down
450
RButton up 
im using SendInput not Send

Edit: btw i change ur code to cs 3 is there any different?
ahmed1234550 is offline  
Old 03/30/2016, 01:38   #12
 
WAZAAAAA...'s Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 91
Received Thanks: 81
...why are you pressing S?

Quote:
Originally Posted by ahmed1234550 View Post
Edit: btw i change ur code to cs 3 is there any different?
it's ok
WAZAAAAA... is offline  
Old 03/30/2016, 01:43   #13
 
elite*gold: 0
Join Date: Apr 2011
Posts: 147
Received Thanks: 5
Quote:
Originally Posted by WAZAAAAA... View Post
...why are you pressing S?

it's ok
idk lol i do dash cancel without macro, only space d+space i dont use s
but i think if u dont have sp better s idk why xd
but dude, yes with s better cuz my code have s works better xD
without s sometimes ignore my click
ahmed1234550 is offline  
Reply

Tags
autohotkey, optimize, performance, precision, timing


Similar Threads Similar Threads
Optimize Dark orbit ?Possible?
08/11/2014 - DarkOrbit - 9 Replies
Hello guys i make Treat here couse darkorbit forums didnt help me at all... I have good hardware (I5 Quad core 3.20GHz 8Gb ram Sapphire 7870 2 Gb..etc.) Windows 7 64-bit... Internet-My country-Frankfurt~~Ping 41 ms Download 31 Mb/s Upload 78 Mb/s(that is good i quess) Browser Firefox/Chrome/Citro same shit (currently there isn't 64 bit browser) And i cant even play Dark Orbit with steady 60 FPS..that is unbeliveable..i get about 50 fps.. Options in AMD Drivers are normal( i get about 120...
Anyone can optimize this code ?
11/30/2013 - CO2 Private Server - 17 Replies
Kindly make this code better guys. I want a port refresher that uses less Cpu usage. static void Port_Refresher() { while (true) { { AuthServer.Disable(); AuthServer = null;
[Release]Optimize Your GrandChase
01/20/2011 - Grand Chase Hacks, Bots, Cheats & Exploits - 17 Replies
This Program is originally from game booster. But this is Lite version made by me. This will make you to run Grand Chase and other programs faster. Instructions: 1. Download the ff file. 2. Extract using winrar.
corn to optimize and repair
11/10/2008 - CO2 Private Server - 1 Replies
hello how make corn to corn to optimize and repair tables every day for more good server without sql problems ???



All times are GMT +2. The time now is 11:21.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.