Problem with a CapsLock (ShiftLock-ish) hotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
edu-hilario
Posts: 8
Joined: 30 Jul 2021, 15:12
Contact:

Problem with a CapsLock (ShiftLock-ish) hotkey

31 Jul 2021, 14:53

Code: Select all

    ~$RShift::
        KeyWait, RShift
        If (A_ThisHotkey = A_PriorHotkey) && (A_TimeSincePriorHotkey < 400)
        SetCapsLockState, % ((GetKeyState("CapsLock", "T") = 1) ? "Off" : "On")
    Return
So, I've been using this hotkey to activate CapsLock for a while now, since I removed the physical key and replace it with Control, via SharpKeys.

But this hotkey has a problem: when CL is activated, and I press the Shift key (any), it goes off.

My goal: I would like to have a hotkey that activate CapsLock by double tapping the Shift key, but when I press down the Shift key—to use an accent or punctuation, or even a lowercase character—the CL still keeps on.

Can you help me?
User avatar
mikeyww
Posts: 26871
Joined: 09 Sep 2014, 18:38

Re: Problem with a CapsLock (ShiftLock-ish) hotkey

31 Jul 2021, 15:16

Since you want to ignore Shift in those situations, you can remove the tilde from the hotkey.
edu-hilario
Posts: 8
Joined: 30 Jul 2021, 15:12
Contact:

Re: Problem with a CapsLock (ShiftLock-ish) hotkey

31 Jul 2021, 22:03

Code: Select all

;CapsLock on RShift
	#ifWinActive
   	~$RShift::
        KeyWait, RShift
        If (A_ThisHotkey = A_PriorHotkey) && (A_TimeSincePriorHotkey < 400)
        SetCapsLockState, % ((GetKeyState("CapsLock", "T") = 1) ? "Off" : "AlwaysOn")
    Return
Just solved it! Thanks to the user @Moo on AHK's Discord for helping me.

The solution was changing the

Code: Select all

On
to

Code: Select all

AlwaysOn
at the end of

Code: Select all

SetCapsLockState

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mapcarter, Marium0505 and 387 guests