Alt Tab快捷方式的AutoHotKey问题

时间:2018-02-06 20:28:48

标签: autohotkey

我试图用AHK创建一个简单的脚本,用这段代码在窗口之间切换(类似于三星手机上的"最近"按钮):

XButton2::
Send, {Alt down}{Tab}
Return

问题是,当我按Enter或单击鼠标左键时,我不知道如何使脚本释放Alt键。 有什么帮助吗?

1 个答案:

答案 0 :(得分:1)

XButton2:: 
    AltTabMenu := true  ; assign the Boolean value "true" or "1" to this variable
    Send, {Alt down}{Tab}
return

; The #If directive creates context-sensitive hotkeys:

#If (AltTabMenu) ; If this variable has the value "true" 

    ; The * prefix fires the hotkey even if extra modifiers (in this case Alt) are being held down

    *Enter::
    *MButton::
        Send {Enter}
        Send {Blind}{Alt Up} ; release Alt
        MouseCenterInActiveWindow()
        AltTabMenu := false
    return

    ~*LButton::
        Click
        Send {Blind}{Alt Up} ; release Alt
        MouseCenterInActiveWindow()
        AltTabMenu := false
    return      

    ; menu navigation by scrolling the mouse wheel:

    *WheelUp:: Send {Right} 
    *WheelDown:: Send {Left}

#If ; turn off context sensitivity

MouseCenterInActiveWindow(){
    WinGetPos,,Y, Width, Height, A ; get active window size
    Xcenter := Width/2        ; calculate center of active window
    Ycenter := Height/2 
    MouseMove, Xcenter, Ycenter, 0
}