Autohotkeys cannot recognize Google Chrome Windows. What can I do?
Solution 1
I use the name only (since Google once changed the class name). Here is an expample in AHK_L that I use.
SetTitleMatchMode, 2
#ifWinActive, Chrome
NumpadIns::Send, {Click}
NumpadRight::Send, ^{PgDn} ; Right arrow = activate next Tab
NumpadLeft::Send, ^{PgUp} ; Left arrow = activate previous tab
#ifWinActive
Solution 2
Try Chrome_WidgetWin_0.
If that doesn't work find out what it's real class is by using WinGet
WinGet,activeId,ID,A <- gives active window ahk_id
WinGetClass, activeClass, ahk_id %activeId%
you can also try to search by name
SetTitleMatchMode, 2
WinGetTitle, OutputVar , Chrome <- type the name of the chrome window ( probably contains chrome)
You can still refer to this question if everything else fails.
Related videos on Youtube
Comments
-
Shluch over 1 year
I am creating a hotkey in autohotkeys, to activate Google Chrome, or move between all Chrome windows.
The HotKey is Win + H (h meaning http).
If the user presses Win + Shift + H it opens a new chrome window
If the user presses Win + H twice, it moves between all chrome windows:
Update: See the full script in the bottom. Thank you everyone:
The problem is that AutoHotKeys cannot find the class of chrome, so it's always open new window:
This function always returns false:
If WinExist ahk_class Chrome_WidgetWin_1
Please advise.
the script file:
#h:: SetTitleMatchMode, 2 If WinExist ahk_class Chrome_WidgetWin_1 { ifWinActive WinActivatebottom ,Chrome_WidgetWin_1 else WinActivate return } run chrome.exe
I found the bug.
There is a bug with ifWinExist function in this version of AutoHotkeys, and Google Chrome. The user can use;
WinActivate ahk_class Chrome_WidgetWin_1
but cannot use:
If WinExist ahk_class Chrome_WidgetWin_1
It is always false!
Hope this question&answer help to someone (I cannot write answer, because I have only 1 reputation point)
Update: This is ahk source code, for Win + n Open Notepad or switching between open notepads.
+ Shift + n Open new notepad.
Win + c Open cmd.exe or switching between console windows.
Win + Shift + c Open new console.
Win + h Open Google Chrome or switching between Chrome windows + Shift + h Open new browser.
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
-
Admin over 11 yearsWhat exactly is the problem? Please paraphrase.
-
Shluch over 11 yearsThis function always return false: IfWinExist ahk_class Chrome_WidgetWin_1
-