autohotkey

How can I get two unique hotkeys out of the same keys, based on the order in which the keys are pressed?


The two hotkeys I want to create are:

Notice they both have the exact same keys, only their order is unique. Here is some of the code I tried to achieve this with:

#if GetKeyState("lshift", "p")
space & f::
tooltip, you presedd lshift & space & f
return

#if GetKeyState("space", "p")
LShift & f::
tooltip, you presedd space & lshift & f
return

I tried other variations with #InputLevel in between the hotkey labels but have not had any success at all.

I am out of ideas her and would love any help or pointers on how to get about achieving this. My goal is create two "modifier" layers:

Thank you


Solution

  • Blind mode

    Modifier keys are restored differently to allow a Send to turn off a hotkey's modifiers even if the user is still physically holding them down. ...

    Space & LShift::Space_LShift := true
    Space & LShift Up::Space_LShift := false
    
    LShift & Space::
        Send {Blind}{Shift Up}
        LShift_Space := true
    return
    
    LShift & Space Up::LShift_Space := false
    
    #If LShift_Space 
        f:: Tooltip, you presedd LShift & Space & f
    #If Space_LShift
        f:: Tooltip, you presedd Space & LShift & f
    #If
    
    ; https://www.autohotkey.com/docs/v1/Hotkeys.htm#combo
    ; To avoid that the prefix key Space loses its native function, add:
    
    Space::Send {Space}