0

I want to map meh+i onto alt+tab in windows. (The meh-key is the combination alt+shift+ctrl).

Is this possible with Autohotkey v2?

Remarks:

  • As I understand the documentation, this is not possible using the AltTab action, as only 2-key-combinations can be mapped onto that action. Correct me if I'm wrong.

  • This means, I need to build this the old way, simulating key presses and waiting for keys to be lifted, is that correct?

    I found this old thread, and I've adapted it to what I assume is the correct syntax for v2:

    #!^i:: {
      Send "{ALT DOWN}{TAB}" ; If i is down it invokes the menu for switching windows.
      KeyWait "i" ; Show menu for switching windows by keeping ALT down until user physically releases i.
      Send "{ALT UP}" ; If i is released release ALT key
    }
    return
    

    However, this only works for "one press"; repeated presses of i do not move the selected window further.

I assume I have to build-in some loop that waits for a repeated press of the i key, and that drops out of the loop as soon as any of the modifiers is released.

(Why want to do this remapping at all? I use meh+key for window management operations: move a window around, move focus to another window, move to another desktop, etc. Alt-tab belongs in that group, so I want to have the same "prefix" as the other operations.)

ElRudi
  • 2,122
  • 2
  • 18
  • 33

1 Answers1

1

The meh-key is the combination Left Control + Shift + Alt. Try this:

; #HotIf GetKeyState("Shift") and GetKeyState("Alt") ; redundant

    LCtrl & i::AltTab

; #HotIf ; redundant

EDIT:

Alt-Tab Hotkeys says

Alt-tab actions are not affected by #HotIf.

that is

LCtrl & i::AltTab

can work in this case without the #HotIf directive.

My apologies for misleading you.

EDIT 2:

If your keyboard layout has a left Control key, and you don't want AltTab to be fired on both left Control + i and meh-key + i, try this:

#Requires AutoHotkey v2.0
    
; LCtrl+Alt+Shift+i  = meh-key+i  = AltTab

<^+!i:: {
  Send "{Alt Down}{Tab}"
  AltTabMenu := true  ; assign the Boolean value "true" or "1" to the variable "AltTabMenu"
}

; The #HotIf directive creates context-sensitive hotkeys and hotstings:

#HotIf (AltTabMenu := true) ; If this variable has the value "true"
    
    ~*LCtrl Up::
    ~*Alt Up::
    ~*Shift Up::
    {
        Send "{Alt Up}"
        AltTabMenu := false 
    }

#HotIf  ; turn off context sensitivity
user3419297
  • 9,537
  • 2
  • 15
  • 24