Different action depending on how many times the key is pressed

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tatagi
Posts: 181
Joined: 23 Aug 2018, 11:17

Different action depending on how many times the key is pressed

17 Apr 2021, 20:51

can this be done with autohotkey?

for example,
let's say you assigned a hotkey like below

ctrl + 1 ---> send a


then if you press ctrl + 11(press 1 twice while ctrl is pressed), it sends "aa" by default.


I want to change this action to sending "b"

how can I do this? thank you!
User avatar
boiler
Posts: 16974
Joined: 21 Dec 2014, 02:44

Re: Different action depending on how many times the key is pressed

17 Apr 2021, 21:43

Try this:

Code: Select all

^1::
	OneCount := 0
	loop {
		if (OneCount = 0 && !GetKeyState("1", "P"))
			OneCount := 1
		if (OneCount = 1 && GetKeyState("1", "P"))
			OneCount := 2
	} until !GetKeyState("Ctrl", "P")
	Send, % OneCount = 1 ? "a" : "b"
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, DataLife, ShatterCoder and 269 guests