这种不冷门的问题,在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)
}
}