Reputation: 259
I would like to see if I have active Chrome, but not in other webpage but in a specific page.
If I use
IfWinExist ahk_class Chrome_WidgetWin_1
the script will find ALSO Chrome opened with other webpages, and I don't want that.
What should I do?
Upvotes: 3
Views: 2200
Reputation: 1430
I'm not sure i quite understood what do you want to achieve but i once wrote a script to loop through all Chrome tabs, here is a slightly adjusted so it will go through all tabs and activate the one you want:
^!Space::
{
IsSiteOpen()
return
}
IsSiteOpen()
{
Global TabTitleExist
TabTitle = autohotkey
SetTitleMatchMode 2
IfWinExist, %TabTitle%
{
WinActivate, %TabTitle%
WinMinimize, %TabTitle%
MsgBox, 64, %TabTitle%, It is open
return
}
LoopChromeTabs(TabTitle)
if (TabTitleExist = 1)
{
WinActivate, %TabTitle%
WinMinimize, %TabTitle%
MsgBox, 64, %TabTitle%, It is open
return
}
return
}
LoopChromeTabs(TabTitle)
{
Global TabTitleExist
IfWinExist, ahk_class Chrome_WidgetWin_1
{
; Get current open tab title
WinGetTitle, FirstTitle
; Go through all open tabs and find the tab we are looking for or quit
Loop
{
WinActivate ahk_class Chrome_WidgetWin_1
Send ^{Tab}
WinGetTitle, CurrentTitle
; After we changed tab have we found our tab?
IfWinExist, %TabTitle%
{
TabTitleExist = 1
break
}
; We went through all tabs and we should stop there
If (FirstTitle = CurrentTitle)
break
}
}
}
https://github.com/ilirb/ahk-scripts/blob/master/executable/source/GoogleMusicRemote.ahk
Upvotes: 2