AHK works sporatically

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bookends623
Posts: 2
Joined: 13 Aug 2019, 11:48

AHK works sporatically

Post by bookends623 » 13 Aug 2019, 15:17

AHK Unicode 64 Ver 1.1.30.03

I just started with AHK. I wrote a script with 4 hot keys and compiled it.
The problem: sometimes the hot keys work and sometime they do nothing.
That kind of reliability renders them of little value. Sometimes two will
work and two won't. I never know when I press the hot key if anything will
come out. And sometimes everything will come out except the enter at the
end--and other times the enter will come out. Very mysterious why this
should be so.
Thanks for listenin'.

Here is my script:

Code: Select all

#SingleInstance ignore
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory. 

^t::  ;  ^=CTRL
Send, tedL1234 
Send, {Tab}
Send, Ted324med 
Send, {Return}
return

^j::  ;  ^=CTRL
Send, janetL2345 
Send, {Tab}
Send, Kwat623jan
Send, {ENTER}
return

^+r::  ;   CTRL+SHIFT+r     + means SHIFT
Send, tedL1234
Send, {Tab}
Send, Ted324opt
Send, {Enter}
return

^+x::   ;   CTRL+SHIFT+x   + means SHIFT
Send, janetL  
Send, {Tab}
Send, Kwat623jan
Send, {Enter}
return
[Mod edit: [code][/code] tags fixed; topic moved to 'Ask For Help', since it's about AHK v1.1, not v2]

teadrinker
Posts: 4412
Joined: 29 Mar 2015, 09:41
Contact:

Re: AHK works sporatically

Post by teadrinker » 13 Aug 2019, 21:02

Try using #UseHook or $ prefix.

User avatar
evilC
Posts: 4824
Joined: 27 Feb 2014, 12:30

Re: AHK works sporatically

Post by evilC » 14 Aug 2019, 06:45

If an application only sees keys send by the script intermittently, Delete the line SendMode, Input and add the line SetKeyDelay, 0, 50 in it's place.
The problem is that the game is polling for key state (Likely once every 50ms or so) and when it does not work, what is happening is that AHK is pressing and releasing the key between on poll and the next, so the game sees nothing. Using the SetKeyDelay command ensures all keys are held for 50ms, so the press will always be in one poll, and the release in the next

Post Reply

Return to “Ask for Help (v1)”