Autohotkeys 无法识别 Google Chrome Windows。我能做什么?

Shl*_*uch 5 google-chrome shortcuts autohotkey

我正在自动热键中创建一个热键,以激活 Google Chrome,或在所有 Chrome 窗口之间移动。

热键是Win+ H(h 表示 http)。

如果用户按下Win+ Shift+H它会打开一个新的 chrome 窗口

如果用户按Win+H两次,它将在所有 chrome 窗口之间移动:

更新:请参阅底部的完整脚本。谢谢大家:

问题是 AutoHotKeys 找不到 chrome 的类,所以它总是打开新窗口:

此函数始终返回 false: If WinExist ahk_class Chrome_WidgetWin_1

请指教。

脚本文件:

#h::
SetTitleMatchMode, 2
If WinExist ahk_class Chrome_WidgetWin_1
{
ifWinActive
WinActivatebottom ,Chrome_WidgetWin_1
else
WinActivate 
return
}
run chrome.exe
Run Code Online (Sandbox Code Playgroud)

我发现了这个错误。

此版本的 AutoHotkeys 和 Google Chrome 中的 ifWinExist 函数存在错误。用户可以使用;

WinActivate ahk_class Chrome_WidgetWin_1
Run Code Online (Sandbox Code Playgroud)

但不能使用:

If WinExist ahk_class Chrome_WidgetWin_1
Run Code Online (Sandbox Code Playgroud)

永远是假的!

希望这个问答对某人有帮助(我不能写答案,因为我只有 1 个声望点)

更新: 这是 ahk 源代码,用于 Win+n打开记事本或在打开的记事本之间切换。

+ Shift+n打开新的记事本。

Win+c打开 cmd.exe 或在控制台窗口之间切换。

Win+ Shift+c打开新控制台。

Win+h打开 Google Chrome 或在 Chrome 窗口之间切换 + Shift+h打开新浏览器。

SetTitleMatchMode, 2


;********command line
#c::
IfWinExist ,cmd.exe
{
ifWinActive
WinActivatebottom ,cmd.exe
else
WinActivate
return
}
#+c::
run cmd.exe
return

;******************Chrome
#h::
IfWinExist ,Chrome
    {
    ifWinActive
        {
        WinActivatebottom ,Chrome
    }
    else
    {
        WinActivate
    }
    return
}

#+h::
run "chrome"
return 
;**************Notepad
#n::
IfWinExist ,Notepad
    {
    ifWinActive
        {
        WinActivatebottom ,Notepad
    }
    else
    {
        WinActivate
    }
    return
}

#+n::
run "notepad"
return
Run Code Online (Sandbox Code Playgroud)

Rob*_*ink 3

我只使用名称(因为 Google 曾经更改过类名)。这是我使用的 AHK_L 中的示例。

SetTitleMatchMode, 2

#ifWinActive, Chrome
    NumpadIns::Send, {Click}
    NumpadRight::Send, ^{PgDn} ; Right arrow = activate next Tab
    NumpadLeft::Send, ^{PgUp} ; Left arrow = activate previous tab
#ifWinActive
Run Code Online (Sandbox Code Playgroud)