Can't make key be held down Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Cerulium
Posts: 1
Joined: 10 May 2024, 14:46

Can't make key be held down

Post by Cerulium » 10 May 2024, 14:55

Yesterday I noticed I cannot make a key be held down to continuously send the key.

Code: Select all

\::
Send, {o down}
return
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.]

User avatar
boiler
Posts: 17206
Joined: 21 Dec 2014, 02:44

Re: Can't make key be held down  Topic is solved

Post by boiler » 10 May 2024, 15:46

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	\ 

Rohwedder
Posts: 7718
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Can't make key be held down

Post by Rohwedder » 11 May 2024, 02:51

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}
}

Post Reply

Return to “Ask for Help (v1)”