I need a script that will hold w if I hold the space bar but send the r key and the down arrow if I just tap the space

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Tezz95
Posts: 4
Joined: 12 Nov 2015, 19:02

I need a script that will hold w if I hold the space bar but send the r key and the down arrow if I just tap the space

12 Nov 2015, 19:12

Hey guys, I have no skill in script writing and I need a script that will hold w if I hold the space bar but send the r key and the down arrow if I just tap the space bar...Is that even possible? Thanks in advance.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: I need a script that will hold w if I hold the space bar but send the r key and the down arrow if I just tap the spa

12 Nov 2015, 19:36

What you're asking for is tricky for a novice, but can be done. All of the commands below should have hyperlinks for you in the codebox. You can check out the keylist too. Oh, and I use an operator (!) too. Oh, and blocks can be a good thing to read about too.

Code: Select all

space::
KeyWait, space, T0.5 ; waits half a second for you to release it
If !ErrorLevel ; the ! means "NOT". There was no error - you released it quickly
Send r{down}
else ; else you were still holding it down
{
Send {w down}
KeyWait, space ; waits indefinitely for you to release the key
Send {w up}
}
return

Esc::ExitApp
I added the Escape key hotkey to close the script just because this does overwrite the space function in every program.

If you want the space hotkey to work only in a certain program, check out #IfWinActive
Tezz95
Posts: 4
Joined: 12 Nov 2015, 19:02

Re: I need a script that will hold w if I hold the space bar but send the r key and the down arrow if I just tap the spa

12 Nov 2015, 19:55

Exaskryz wrote:What you're asking for is tricky for a novice, but can be done. All of the commands below should have hyperlinks for you in the codebox. You can check out the keylist too. Oh, and I use an operator (!) too. Oh, and blocks can be a good thing to read about too.

Code: Select all

space::
KeyWait, space, T0.5 ; waits half a second for you to release it
If !ErrorLevel ; the ! means "NOT". There was no error - you released it quickly
Send r{down}
else ; else you were still holding it down
{
Send {w down}
KeyWait, space ; waits indefinitely for you to release the key
Send {w up}
}
return

Esc::ExitApp
I added the Escape key hotkey to close the script just because this does overwrite the space function in every program.

If you want the space hotkey to work only in a certain program, check out #IfWinActive
I'm not sure why but while in Windows this works perfectly, in the actual program only the holding down w is working..
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: I need a script that will hold w if I hold the space bar but send the r key and the down arrow if I just tap the spa

12 Nov 2015, 20:04

It could be that you need the keys to be held down longer. So try this change:

Code: Select all

; ...
If !ErrorLevel
{
Send {r down}{down down}
Sleep 400 ; make this shorter as you see fit
Send {r up}{down up}
}
else
; ...
Additionally, you can check out a thread for game troubleshooting. (Note: This is from the old forums) http://www.autohotkey.com/board/topic/1 ... he-basics/
Tezz95
Posts: 4
Joined: 12 Nov 2015, 19:02

Re: I need a script that will hold w if I hold the space bar but send the r key and the down arrow if I just tap the spa

13 Nov 2015, 07:40

Exaskryz wrote:It could be that you need the keys to be held down longer. So try this change:

Code: Select all

; ...
If !ErrorLevel
{
Send {r down}{down down}
Sleep 400 ; make this shorter as you see fit
Send {r up}{down up}
}
else
; ...
Additionally, you can check out a thread for game troubleshooting. (Note: This is from the old forums) http://www.autohotkey.com/board/topic/1 ... he-basics/
That seems to have fixed it! Huge, huge thanks for your help!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], joefiesta and 291 guests