Page 1 of 1
Can't make key be held down
Posted: 10 May 2024, 14:55
by Cerulium
Yesterday I noticed I cannot make a key be held down to continuously send the key.
I've tried every form of the code above I can think of, every send method I can think of, and in another script. It sends o once or not at all depending on send method. I don't know when this started and have no idea what's causing it. I've restarted my pc. Any ideas?
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
Re: Can't make key be held down Topic is solved
Posted: 10 May 2024, 15:46
by boiler
I imagine that it actually is holding the key down. It's just not having the result you expect. Check the
KeyHistory, and I'm confident you'll see that
o was pressed down and was not released, like this:
Code: Select all
DC 02B d 38.19 \ CodeQuickTester*
4F 018 i d 0.00 o
DC 02B u 0.11 \
Re: Can't make key be held down
Posted: 11 May 2024, 02:51
by Rohwedder
Hallo,
see:
https://www.autohotkey.com/docs/v1/misc/RemapController.htm#auto-repeating-controller-buttons
Some programs or games might require a key to be sent repeatedly (as though you are holding it down on the keyboard)
Try:
Code: Select all
\::Repeat("o", 30) ; a Timer sends {Blind}{o Down} every 30 ms
q::Repeat("o") ; deletes the Timer and sends {Blind}{o Up}
Repeat(Key, Period:=0) {
Static Repeat := {}
Repeat[Key] ?: Repeat[Key] := Func("KeyDown").Bind(Key)
Timer := Repeat[Key]
SetTimer,% Timer,% Period ? Period : "Delete"
SendInput,% Period?"":"{Blind}{" Key " Up}" Repeat[Key]:=""
} KeyDown(Key) {
SendInput, {Blind}{%Key% Down}
}