Press/Hold script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
isuckatahk
Posts: 36
Joined: 12 Mar 2020, 02:56

Press/Hold script

12 Jun 2021, 16:06

Trying to make a script that works like this, when i press f9 it will send, a but if i hold f9 it'll Send, b instead.
Currently this script works but for some reason it presses a after i release from holding and i'm not sure how to stop it from doing so.

If anyone help i would be greatful, Thanks in advance.

Code: Select all

F9::
KeyWait, F9, T.3
If ErrorLevel
Send b
Else
{
Send, a	
KeyWait, F9
}
Return
[Mod edit: [code][/code] tags added.]
User avatar
mikeyww
Posts: 26932
Joined: 09 Sep 2014, 18:38

Re: Press/Hold script

12 Jun 2021, 16:19

Code: Select all

F9::
KeyWait, F9, T.3
Send % ErrorLevel ? "b" : "a"
KeyWait, F9
Return
isuckatahk
Posts: 36
Joined: 12 Mar 2020, 02:56

Re: Press/Hold script

12 Jun 2021, 16:25

works just how i want, thanks! I was wondering is there a way to implement if presses = 2 so if i press F9 twice within Set time it will press c? like 1 press sends a, 2 presses sends c, holding down sends b?
isuckatahk
Posts: 36
Joined: 12 Mar 2020, 02:56

Re: Press/Hold script

12 Jun 2021, 16:27

i was using a multitap script but the response time is terrible wanted to see if i could get a faster response in a different script.
isuckatahk
Posts: 36
Joined: 12 Mar 2020, 02:56

Re: Press/Hold script

12 Jun 2021, 16:43

with the script you made is there a way to add sleep between each key? normally i do

Send, A
Sleep , 500
Send,B
User avatar
mikeyww
Posts: 26932
Joined: 09 Sep 2014, 18:38

Re: Press/Hold script

12 Jun 2021, 17:27

Here is nice "tap, double, hold" script from Rohwedder.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: alawsareps, mebelantikjaya, mikeyww, RussF and 308 guests