【问题标题】:Move between Chrome windows using Autohotkey shortcuts使用 Autohotkey 快捷键在 Chrome 窗口之间移动
【发布时间】:2015-06-21 01:36:12
【问题描述】:

我花了几个小时试图弄清楚如何使用 Autohotkey 快捷方式在特定的 Chrome 窗口之间切换。

我有两台显示器。左侧监视器 (nr 1) 在 Chrome localhost 窗口和 Vim 编辑器之间垂直分割。右侧显示器(nr 2)有 Chrome 全屏显示我的 gmail、搜索标签等。

我想在带有 ahk 快捷方式的窗口之间切换,例如Alt+1(本地主机监视器 nr 1),Alt+2(Chrome 窗口监视器 nr 2)。

如果窗口有不同的标题,这很容易做到。我尝试了标题、文本、ahk_id、ahk_class、sysget(更改焦点监视器)、鼠标点击(被其他窗口覆盖)等。似乎没有什么能始终如一地工作,也无法谷歌任何明智的答案。

有什么想法吗?

【问题讨论】:

    标签: windows google-chrome autohotkey


    【解决方案1】:

    此代码应该适合您。一个热键可激活最左侧的 chrome 窗口。另一个激活最右边的

    CoordMode, Pixel, Screen
    
    !1::
        ChromeList := GetWinListByClass("Chrome_WidgetWin_1")
    
        LeftmostPos := 9999
        LeftmostId := ""
        Loop, % ChromeList.MaxIndex()
        {
            currentId := ChromeList[A_Index][1]
            currentX := ChromeList[A_Index][2]
    
            if (currentX < LeftmostPos)
            {
                LeftmostPos := currentX
                LeftmostId := currentId
            }
        }
    
        WinActivate, % "ahk_id" LeftmostId
        Return
    
    !2::
        ChromeList := GetWinListByClass("Chrome_WidgetWin_1")
    
        RightmostPos := -9999
        RightmostId := ""
        Loop, % ChromeList.MaxIndex()
        {
            currentId := ChromeList[A_Index][1]
            currentX := ChromeList[A_Index][2]
    
            if (currentX > RightmostPos)
            {
                RightmostPos := currentX
                RightmostId := currentId
            }
        }
    
        WinActivate, % "ahk_id" RightmostId
        Return
    
    
    GetWinListByClass(filterClass)
    {
        WinGet, all, list
        ChromeList := {}
        winCount := 1
        Loop, %all%
        {
            WinGetClass, WClass, % "ahk_id " all%A_Index%
            if (WClass = filterClass)
            {
                winId := all%A_Index%
                WinGetPos, X, Y, W, H, % "ahk_id " winId 
                ChromeList[winCount] := [winId, X]
                winCount++
            }
        }
        return ChromeList
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-06
      • 1970-01-01
      • 2011-09-18
      • 2022-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多