Autohotkeys cannot recognize Google Chrome Windows. What can I do?
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.exeI 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_1but cannot use:
If WinExist ahk_class Chrome_WidgetWin_1It 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, forWin + 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 2 2 Answers
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 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.