Loop Works, Key Press does not

Ask gaming related questions (AHK v1.1 and older)
N3KR05
Posts: 1
Joined: 15 Jul 2017, 14:16

Loop Works, Key Press does not

15 Jul 2017, 14:25

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?
neomulemi6
Posts: 216
Joined: 30 Jun 2016, 06:01

Re: Loop Works, Key Press does not

16 Jul 2017, 19:13

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:

Code: Select all

Numpad1::
SetKeyDelay, 0, 2000
Send k
SetKeyDelay, 0, 50
Send {LShift}{RButton}
Sleep 1000
Send {LCtrl}
SetKeyDelay, -1
Return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: ReyAHK and 72 guests