Problem
When a 3 key hotkey (LShift
+CapsLock
+LButton
) is pressed, the a similar 2 key hotkey (CapsLock
+LButton
) is triggered instead.
Questions
Why is this happening?
How can the correct message box (
shift left click
) be triggered for theLShift
+CapsLock
+LButton
hotkey?
Code
SetCapsLockState, AlwaysOff
CapsLock::
MsgBox, "capslock"
return
CapsLock & LButton::
MsgBox, "left click"
return
; 3 key hotkey
; problem here is when LShift+CapsLock+LButton are pressed, the CapsLock+LButton is
; triggered instead
#If GetKeyState("LShift", "P") && GetKeyState("CapsLock", "P")
LButton::
MsgBox, "shift left click"
return
#If
Example scenario
- Press
CapsLock
, and correct message box (capslock
) appears - Press
CapsLock
+LButton
, and correct message box (left click
) appears - Press
LShift
+CapsLock
+LButton
, and incorrect message box (left click
) appears (message box (shift left click
) should have appeared) - Press
CapsLock
+LShift
+LButton
, and incorrect message box (left click
) appears (message box (shift left click
) should have appeared)
What I've tried
- Checking the
#If
directive documentation, it mentions a timeout that could affect the button combination, however, pressing the buttons at varying speeds still causes theCapsLock
+LButton
hotkey to trigger - Using nested regular
if
,else if
, &else
statements instead of the#If
directive to alter the order of the 3 key hotkey - Using
$
modifer to prevent the 3 key hotkey triggering theCapsLock
+LButton
hotkey Breaking the 3 key hotkey into parts, e.g., putting a 2 key hotkey within a
#If
GetKeyState
, i.e.:#If GetKeyState("LShift", "P") CapsLock & LButton:: MsgBox, "shift left click" return #If
This usually gives the correct message (
shift left click
) box but sometimes triggers the CapsLock hotkey giving the incorrect message box (capslock
)
if (GetKeyState("LShift", "P"))
in theCapsLock & LButton
hotkey? – Josh Brobstif (GetKeyState("LShift", "P"))
inCapsLock & LButton
with#If
and regularif
/else
both stopCapsLock & LButton
& the 3 key hotkey firing theirMsgBox
– surajs02LShift
is the last key released after the hotkey is triggered, e.g.,LShift
down+CapsLock
down thenCapsLock
up+LShift
up correctly doesn't triggerCapsLock
hotkey butCapsLock
hotkey is triggered if CapsLock is the last key released after the hotkey is triggered) – surajs02