高亮当前窗口

需求

能够高亮当前窗口边框(像OBS选择窗口对象录屏时出现的这种边框效果),或者调暗非活动窗口。Windows自带的这种标题栏变暗的效果太不明显了,而且视频全屏(外接了一个屏幕,所以两个窗口能分别在两个屏幕上)的时候更是不方便
不知道AHK能实现这种效果吗?论坛里的手搓大佬们是否有过这种想法?

OBS选择窗口录屏出现边框效果提示:
image

OBS不选择该窗口:
image

场景

经常在两个窗口间来回切换,比如一个浏览器窗口看着视频,一个笔记窗口记着笔记,但有时候又会切到第三个窗口,导致窗口顺序打乱,Alt-Tab之后想用快捷键调视频进度/播放/速度,却发现实际到了别的窗口,而自己却要等个几秒才能反应过来,这种体验很不爽

这种不冷门的问题,在autohotkey论坛一搜就有了。
在活动窗口 V2 周围绘制边框?- AutoHotkey 社区

; V1 ======================================
SetTimer, DrawRect, 100
; DrawRect()
; windows in windows 10 has thick invisible boarder which is about 4 pixels wide.
DrawRect:
    border_thickness = 3
    ; set the color of the border
    border_color = red
    ; set the color of the border
    ; Get the current window's position
    ; WinWaitActive ahk_class PotPlayer64
    WinGetPos, x, y, w, h, A
    ; WinGetPos, x, y, w, h, A
    ; To avoid the error message
    if (x="")
        return
    ;Gui, +Lastfound +AlwaysOnTop +Toolwindow
    Gui, +Lastfound +AlwaysOnTop
    ; set the background for the GUI window
    Gui, Color, %border_color%
    ; remove thick window border of the GUI window
    Gui, -Caption
    ; Retrieves the minimized/maximized state for a window.
    WinGet, notMedium , MinMax, A
    if (notMedium==0){
        ; 0: The window is neither minimized nor maximized.
        offset:=0
        outerX:=offset
        outerY:=offset
        outerX2:=w-offset
        outerY2:=h-offset
        innerX:=border_thickness+offset
        innerY:=border_thickness+offset
        innerX2:=w-border_thickness-offset
        innerY2:=h-border_thickness-offset
        newX:=x
        newY:=y
        newW:=w
        newH:=h
        WinSet, Region, %outerX%-%outerY% %outerX2%-%outerY% %outerX2%-%outerY2% %outerX%-%outerY2% %outerX%-%outerY% %innerX%-%innerY% %innerX2%-%innerY% %innerX2%-%innerY2% %innerX%-%innerY2% %innerX%-%innerY%
        Gui, Show, w%newW% h%newH% x%newX% y%newY% NoActivate, GUI4Boarder
        return
    } else {
        WinSet, Region, 0-0 w0 h0
        return
    }
return
#Requires AutoHotkey v2
; V2 ======================================
;Gui, +Lastfound +AlwaysOnTop +Toolwindow
border_thickness := 3
border_color := 'red'
; set the background for the GUI window
G := Gui('+Lastfound +AlwaysOnTop -Caption')
; set the color of the border
G.BackColor := border_color
; remove thick window border of the GUI window
G.Opt('-Caption')
SetTimer(DrawRect, 100)
; DrawRect()
; windows in windows 10 has thick invisible boarder which is about 4 pixels wide.
DrawRect() {
	; set the color of the border
	; Get the current window's position
	; WinWaitActive ahk_class PotPlayer64
	Try
		WinGetPos(&x, &y, &w, &h, 'A')
	Catch As Err {
		Return
	}
	; WinGetPos, x, y, w, h, A
	; To avoid the error message
	; Retrieves the minimized/maximized state for a window.
	notMedium := WinGetMinMax('A')
	if (notMedium == 0) {
		; 0: The window is neither minimized nor maximized.
		offset := 0
		outerX := offset
		outerY := offset
		outerX2 := w - offset
		outerY2 := h - offset
		innerX := border_thickness + offset
		innerY := border_thickness + offset
		innerX2 := w - border_thickness - offset
		innerY2 := h - border_thickness - offset
		newX := x
		newY := y
		newW := w
		newH := h
		WinSetRegion(outerX '-' outerY ' ' outerX2 '-' outerY ' ' outerX2 '-' outerY2 ' ' outerX '-' outerY2 ' ' outerX '-' outerY ' ' innerX '-' innerY ' ' innerX2 '-' innerY ' ' innerX2 '-' innerY2 ' ' innerX '-' innerY2 ' ' innerX '-' innerY, G)
		;WinSet, Region, outerX-outerY outerX2-outerY outerX2-outerY2 outerX-outerY2 outerX-outerY innerX-innerY innerX2-innerY innerX2-innerY2 innerX-innerY2 innerX-innerY
		G.Show('w' newW ' h' newH ' x' newX ' y' newY ' NoActivate')
		;Gui, Show, wnewW hnewH xnewX ynewY NoActivate, GUI4Boarder
	} else {
		WinSetRegion('0-0 w0 h0', G)
	}
}

有办法隐藏掉这个AHK的窗口吗?
任务栏会显示这个AHK任务
image

Alt-Tab切换界面也会显示

    Gui, +Lastfound +AlwaysOnTop

改成

Gui, +Lastfound +AlwaysOnTop +Toolwindow

v2版的这句里加
G := Gui('+Lastfound +AlwaysOnTop -Caption +Toolwindow')

1 个赞