简而言之,我想要 Ctrl+Alt+T 激活 Windows 终端窗口。以前我用过这个:
^!T::
    if WinExist("Windows PowerShell")
        WinActivate
    else
        Run, wt
Return
但这已经不再有效,因为当我使用 Posh Git 时,Windows 终端会更改其标题。
因此,我需要在进程名称为“WindowsTerminal.exe”的任何窗口上激活该窗口。
我已经尝试过,但由于某种原因它无法识别正确的窗口:
^!T::
    if WinExist(ahk_exe "WindowsTerminal.exe")
        WinActivate
    else
        Run, wt
Return
使用进程/exe 的名称调用WinExist的语法不正确
代替:
if WinExist(ahk_exe "WindowsTerminal.exe")
您还需要将ahk_exe其部分包含在引号内。
像这样:
if WinExist("ahk_exe WindowsTerminal.exe")
最终代码:
^!T::
    if WinExist("ahk_exe WindowsTerminal.exe")
        WinActivate
    else
        Run, wt
Return