【问题标题】:AutoHotKey issue with Alt Tab shortcutAlt Tab 快捷方式的 AutoHotKey 问题
【发布时间】:2018-07-17 00:19:27
【问题描述】:

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

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

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

【问题讨论】:

    标签: autohotkey


    【解决方案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
    }
    

    【讨论】:

    • 谢谢@user3419297 但是..当我有超过2个打开的窗口并且我尝试通过用鼠标左键单击切换到前一个窗口(第3个、第4个等)以外的窗口按钮,它不会切换到该窗口。它只是切换到第二个,就像我只是按 Alt & Tab 一次一样。我喜欢使用鼠标滚轮在打开的窗口之间进行选择的想法,但我希望能够通过单击来选择窗口,有什么办法可以解决这个问题吗?
    • 您使用的是什么操作系统(Win7、Win10)?
    • 我在 Windows 10 上
    • 我不明白上次编辑的目的是什么?你能解释一下吗?
    • 它会自动将鼠标指针移动到激活窗口的中心。
    猜你喜欢
    • 2021-06-20
    • 2014-01-12
    • 1970-01-01
    • 1970-01-01
    • 2011-06-14
    • 1970-01-01
    • 2011-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多