AutoHotKey issue with Alt Tab shortcut

℡╲_俬逩灬. 提交于 2019-12-08 04:28:30

问题


i was trying to create a simple script with AHK to switch between windows (similar to the "recent" button on a samsung mobile) with this code:

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

the problem is that i don't know how to make the script to release the Alt key when i strike Enter or click the Left mouse button. Any help please?


回答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
}


来源:https://stackoverflow.com/questions/48651443/autohotkey-issue-with-alt-tab-shortcut

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!