One shortcut, different commands on X number of times pressed.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
theleetbeagle
Posts: 43
Joined: 20 Apr 2020, 14:29

One shortcut, different commands on X number of times pressed.

Post by theleetbeagle » 06 Dec 2022, 15:46

Hello,

Trying to write a script that will perform different commands each time it is pressed. I've found a couple examples here, but none are really what I'm after.

Toggle would work if it was just two, but it's more like four to six.

Basically:

^a:: ;specifically, holding down CTRL the entire time, but pressing A more than once

(if pressed once)
send chicken
return

(if pressed twice quickly)
send duck
return

(if pressed 3x quickly)
send cow
return

(if pressed 4x quickly)
send horse
return

User avatar
mikeyww
Posts: 26611
Joined: 09 Sep 2014, 18:38

Re: One shortcut, different commands on X number of times pressed.

Post by mikeyww » 06 Dec 2022, 16:14

Code: Select all

^a::n++
~Ctrl Up::
SendInput % ["chicken", "duck", "cow", "horse"][n]
n =
Return

theleetbeagle
Posts: 43
Joined: 20 Apr 2020, 14:29

Re: One shortcut, different commands on X number of times pressed.

Post by theleetbeagle » 06 Dec 2022, 16:28

mikeyww wrote:
06 Dec 2022, 16:14

Code: Select all

^a::n++
~Ctrl Up::
SendInput % ["chicken", "duck", "cow", "horse"][n]
n =
Return
Thanks. I got it the way I wanted while this post was in moderation:

Code: Select all

#IfWinActive, ahk_exe explorer++.exe

insert::
	count++
	If count=1 
		{
		send !v
		send o
		send {down 3}
		send {enter}
		send {end}
		}
	If count=2 
		{
		send !v
		send o
		send {down 3}
		send {enter}
		send {end}
		}


	If count=3 
		{
		send !v
		send o
		send {down 2}
		send {enter}
		send {end}
		}	
	If count=4 
		{
		send !v
		send o
		send {down 2}
		send {enter}
		send {end}
		}


	If count=5 
		{
		send !v
		send o
		send {down 1}
		send {enter}
		send {end}
		}
	If count=6 
		{
		send !v
		send o
		send {down 1}
		send {enter}
		send {end}
		}


	If count=7
		{
		send !v
		send o
		send {enter}
		send {end}
		}
	If count=8 
		{
		send !v
		send o
		send {enter}
		send {end}
		count:=0
		}

Post Reply

Return to “Ask for Help (v1)”