Autohotkey:激活X监视器的最前端

时间:2017-04-05 07:15:06

标签: autohotkey

如何在给定的监视器中激活最前面的窗口?假设我有两个显示器,一个带有编辑器,另一个带有不同的应用程序,例如chrome和slack。我想绑定一个键,它将激活监视器2中的最前面的窗口,无论是松弛还是铬,还有一个用于编辑器,以便于操作。

1 个答案:

答案 0 :(得分:1)

The foremost window in a given monitor is the currently active window or (if the currently active window is on the other monitor) the last active window of this monitor.

; activate the editor:
F1::
WinActivate, ahk_exe notepad.exe    ; replace notepad with the ahk_exe of the editor
return

; activate the last active window in the right monitor:
F2::
WinGetPos, X,,,, A
If (X > 1920)   ; replace 1920 with the width of the left monitor
    return  ; do nothing
; otherwise:
WinGet, id, list
Loop, %id%
{
    this_ID := id%A_Index%
    WinGet, exStyle, exStyle, ahk_id %this_ID%
    If !(exStyle & 0x100)
        continue
    WinGetTitle, title, ahk_id %this_ID%
    If (title = "")
        continue
    WinGetPos, X,,,, ahk_id %this_ID%
    If (X > 1920)   ; replace 1920 with the width of the left monitor
    {
        WinActivate, ahk_id %this_ID%       
            break
    }
}
return
相关问题