Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question
    
What exactly is the problem? Please paraphrase. –  user197261 Feb 12 '13 at 19:27
    
This function always return false: IfWinExist ahk_class Chrome_WidgetWin_1 –  Shluch Feb 12 '13 at 19:30
add comment

2 Answers 2

up vote 0 down vote accepted

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
share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.