script that makes it so when a key is pressed, it remains activated until I press it again Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
mindlessplague
Posts: 5
Joined: 09 May 2024, 22:13

script that makes it so when a key is pressed, it remains activated until I press it again

09 May 2024, 22:19

How can I configure ahk so that when I press a key, it remains activated until I press it again? (these being a,d,r) thank you in advance
Rohwedder
Posts: 7713
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: script that makes it so when a key is pressed, it remains activated until I press it again  Topic is solved

10 May 2024, 00:32

Hallo,
try:

Code: Select all

#Requires AutoHotkey v2.0
*a:: {
	Static A := False
	Send (A:=!A)?"{Blind}{a down}":"{Blind}{a up}"
	KeyWait "a"
}
or with AutoRepeat:

Code: Select all

#Requires AutoHotkey v2.0
*a:: {
    Static A := False, T:=()=>Send("{Blind}{a downR}")
    SetTimer(T, 30*A:=!A), A?T():Send("{Blind}{a up}")
	KeyWait "a"
}
Other keys accordingly.
Edit: AutoRepeat version added.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: emp00, mikeyww, songdg and 42 guests