3

我想看看我是否有活动的 Chrome,但不是在其他网页中,而是在特定页面中。

如果我使用

IfWinExist ahk_class Chrome_WidgetWin_1

该脚本会发现 ALSO Chrome 与其他网页一起打开,我不希望这样。

我应该怎么办?

4

1 回答 1

2

我不确定我是否完全理解您想要实现的目标,但我曾经编写过一个脚本来循环浏览所有 Chrome 标签,这里稍作调整,因此它将遍历所有标签并激活您想要的标签:

^!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

于 2013-10-20T16:19:56.033 回答