AutoHotKey:检测 Firefox 组合键中的单键释放

AutoHotKey: detect single key release in keycombo for Firefox

尝试在 AutoHotKey 的帮助下将组合键 Alt+Tab 配置为在 Firefox 中表现为 tab switcher

#IfWinActive Showcase
    LAlt & Tab::Send {tab}
    GetKeyState, state, LAlt
    if state = U
        Send {enter}

基本上这可以防止 Alt+Tab 调出 Windows 和循环的普通 window 切换器通过打开的选项卡,因为 Tab 被推送。然而,当我试图模拟 Windows' window 切换器的行为时,我也希望它能够显示 – Send {enter}Left 时最后选择的选项卡Alt 发布。 这我似乎无法完成,因为 GetKeyState 只是不会响应,即使 state 变成 U。在这种情况下如何检测按键释放?


添加:
所以我最终得到了以下代码,它的主要部分做了我想要的:



    #IfWinActive ahk_exe firefox.exe  <i>; Alt+Tab to Windows</i>
        LAlt & tab::
        Send {F10}  <i>; F10 brings up Showcase in my FF installation</i>
        WinWaitActive Showcase
        GetKeyState, state, LAlt, P
            if state = U
                WinClose Showcase
        IfWinNotActive Showcase
            Send {LWin}
    #IfWinActive Showcase  <i>; Alt+Tab over Firefox’s tabs</i>
        LAlt & tab::
        Send {tab}
        SetTimer, choice, -50
        return
        choice:  <i>; Thanks, <a href="">@user3419297</a>!</i>
            KeyWait, LAlt, P
            IfWinActive Showcase
                Send {LAlt up} {space}
        return
    #IfWinActive ahk_exe firefox.exe  <i>; Win+Tab over Firefox’s tabs</i>
        LWin::F10
    #IfWinActive Showcase  <i>; Win+Tab to Windows</i>
        tab::return
        LWin & tab::
        WinClose Showcase
        WinWaitClose Showcase
        WinMinimize ahk_exe firefox.exe
        Send {LWin down} {tab} {LWin up}
    return
    ExitApp


这实际上模拟了 Firefox 中的 Alt+ 和 Win+Tab 行为,我通常在全屏模式下使用:

因为我以前不知道任何 AutoHotKey,回想起来这可能是一个有点矫枉过正的任务。然而,这确实迫使我 实际学习 如何在 AHK 中编程,同时磨练我的整体编程技能。为此,这很棒。我经常发现自己本能地在 Firefox 中按下 Alt+Tab 以循环浏览选项卡,就像使用 windows 一样,只会被提醒这实际上只适用于 Windows 中的 windows。直到最近,那就是:)

#IfWinActive Showcase

    LAlt & Tab:: 
        Send {Tab}
        SetTimer Send_Enter, -50
    return

#IfWinActive     ; turn off context sensitivity

Send_Enter:
    KeyWait, LAlt, L
    Send {Alt Up}{Enter}
return