Ctrl key stuck down

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Kaptah
Posts: 8
Joined: 15 Jul 2022, 10:09

Ctrl key stuck down

Post by Kaptah » 30 Nov 2023, 06:01

Hello,

I have this script

Code: Select all

^F12::
{
	Send '^a'
	Sleep 150
	Send '^x'
	Sleep 150
	Send '{F2}'
	Sleep 150
	Send '^x'
	Sleep 150
	Send '{Enter}'
	Sleep 150
	Send '^d'
	Sleep 150
	Send '{Enter}'
	Sleep 150
}
After running it, Windows behaves like Ctrl key is constantly held down.
I have to shutdown AutoHotkey and use some Ctrl key combo to get back to normal state.
What might be the problem?

I tried to add line

Code: Select all

	Send '{Ctrl Up}'
It did not solve it

Thanks in advance :)

niCode
Posts: 312
Joined: 17 Oct 2022, 22:09

Re: Ctrl key stuck down

Post by niCode » 30 Nov 2023, 13:44

I couldn't reproduce your issue. Normally when a key is continued to be held down, you just have to press that key again to fix it, not end the script. Is this the only thing in your script?

Does this shortened version make any difference?

Code: Select all

^F12::
{
    SendMode('Event')
    SetKeyDelay(150)
	Send('^a^x{F2}^x{Enter}^d{Enter}')
}

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

Re: Ctrl key stuck down

Post by mikeyww » 30 Nov 2023, 13:56

Conflicting software can have this effect. One potential solution or idea to test is below.

Code: Select all

#Requires AutoHotkey v2.0

^F12 Up:: {
 KeyWait 'Ctrl'
 Send '^a'
}

Kaptah
Posts: 8
Joined: 15 Jul 2022, 10:09

Re: Ctrl key stuck down

Post by Kaptah » 30 Nov 2023, 15:46

Thanks for both!
Got it cleaner and working. I made a small change to key sequence.

Code: Select all

^F12 Up::
{
	KeyWait 'F2'
	SetKeyDelay (150)
	Send ('{F2}^x{Enter}^a^x^d{Enter}')
}

niCode
Posts: 312
Joined: 17 Oct 2022, 22:09

Re: Ctrl key stuck down

Post by niCode » 30 Nov 2023, 17:56

Kaptah wrote:
30 Nov 2023, 15:46
Thanks for both!
Got it cleaner and working. I made a small change to key sequence.

Code: Select all

^F12 Up::
{
	KeyWait 'F2'
	SetKeyDelay (150)
	Send ('{F2}^x{Enter}^a^x^d{Enter}')
}
Unless you're changing the default SendMode somewhere else in the global part of the script, SetKeyDelay has no effect here. It doesn't affect SendInput which is used by default when using Send. So if the hotkey is working fine and you haven't changed the SendMode, you can remove SetKeyDelay.

dgbchr
Posts: 1
Joined: 24 Oct 2021, 00:37

Re: Ctrl key stuck down

Post by dgbchr » 02 Dec 2023, 00:46

mikeyww wrote:
30 Nov 2023, 13:56
Conflicting software can have this effect.
I experience sticky control and other modifier keys all the time. The only software I can think of which might qualify as "conflicting" is KeyTweak ... but since KeyTweak operates (as I understand it) at a lower level than AutoHotKey, I imagine that it should not cause conflicts, and should not be to blame for my sticky modifier keys ... or could it?

It's also mentioned in AHK's own documentation (https://www.autohotkey.com/docs/v2/misc/Remap.htm), another reason why I am hesitant to blame it for my troubles.

Any other tips for how I can trouble shoot my sticky modifier keys? (I can post my script if that would help someone help me ...)

Thanks!

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

Re: Ctrl key stuck down

Post by mikeyww » 02 Dec 2023, 07:03

Without specific investigation, I don't think you will be able to predict or guess the program that conflicts or does not conflict. You could see the other posts about this issue. I am not aware of any universal preventive strategy aside from identifying (and then handling) the conflicting software. I simply use an "emergency reset" hotkey for these situations. It sends up the modifier keys.

Post Reply

Return to “Ask for Help (v2)”