I'm going to preface by saying that the extent of my AHK ability so far has been making a loop to press space bar. I recently tried to create a script where if I press the Numpad1 key, it executes the script and presses a series of buttons. Just to make sure my script worked, I opened up a blank notepad and tried the hotkey and it ran as expected. But when I pressed the hotkey ingame, nothing happened (I tried compiling the script and running as admin and both of those options together). The weird thing is, if I change the key-press into a loop, then the script works fine in game, but I really need it to just run whenever I push a button.
Numpad1::
{
Send {k down}
Sleep 2000
Send {k up}
Send {LShift down}
Sleep 50
Send {LShift up}
Sleep 50
Send {RButton down}
Sleep 50
Send {RButton up}
Sleep 1000
Send {LControl down}
Sleep 50
Send {LControl up}
Sleep 50
}
Return
Any ideas what I can do?
Loop Works, Key Press does not
-
- Posts: 216
- Joined: 30 Jun 2016, 06:01
Re: Loop Works, Key Press does not
You could try removing the brackets. I doubt they're causing your problem, but they're also serving no purpose. Also, you can use SetKeyDelay to make your script a little neater.
This does the same thing as your script:
This does the same thing as your script:
Code: Select all
Numpad1::
SetKeyDelay, 0, 2000
Send k
SetKeyDelay, 0, 50
Send {LShift}{RButton}
Sleep 1000
Send {LCtrl}
SetKeyDelay, -1
Return
Who is online
Users browsing this forum: ReyAHK and 72 guests