Page 1 of 1

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

Posted: 09 May 2024, 22:19
by mindlessplague
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

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

Posted: 10 May 2024, 00:32
by Rohwedder
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.

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

Posted: 10 May 2024, 00:42
by mindlessplague
It worked ty :)