这是一个窗口置顶工具的ahk的代码。画红框参考了一下别人的代码。
习惯使用ahk的话,就可以不用安装别的软件了。快捷键是win+c,当前窗口会置顶,而且周围有红框显示。
复制代码保存成ahk后缀的文件就可以运行。
autohotkey的具体用法可以看官网:https://www.autohotkey.com/
#Persistent
border_thickness = 5
border_color = FF0000
DrawRect:
WinGetPos, x, y, w, h, %WinTitle%
if (x="")
return
Gui, guiborder: +Lastfound +AlwaysOnTop +Toolwindow
borderType:="outside" ; set to inside, outside, or both
if (borderType="outside") {
outerX:=0
outerY:=0
outerX2:=w+2*border_thickness
outerY2:=h+2*border_thickness
innerX:=border_thickness
innerY:=border_thickness
innerX2:=border_thickness+w
innerY2:=border_thickness+h
newX:=x-border_thickness
newY:=y-border_thickness
newW:=w+2*border_thickness
newH:=h+2*border_thickness
} else if (borderType="inside") {
WinGet, myState, MinMax, A
if (myState=1)
offset:=8
else
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
} else if (borderType="both") {
outerX:=0
outerY:=0
outerX2:=w+2*border_thickness
outerY2:=h+2*border_thickness
innerX:=border_thickness*2
innerY:=border_thickness*2
innerX2:=w
innerY2:=h
newX:=x-border_thickness
newY:=y-border_thickness
newW:=w+4*border_thickness
newH:=h+4*border_thickness
}
Gui, guiborder: Color, %border_color%
Gui, guiborder: -Caption
WinSet, Region, %outerX%-%outerY% %outerX2%-%outerY% %outerX2%-%outerY2% %outerX%-%outerY2% %outerX%-%outerY% %innerX%-%innerY% %innerX2%-%innerY% %innerX2%-%innerY2% %innerX%-%innerY2% %innerX%-%innerY%
Gui, guiborder: Show, w%newW% h%newH% x%newX% y%newY% NoActivate, Table awaiting Action
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;drawreact reference https://superuser.com/a/739000
#Persistent
BorderOn := False
#c::
If BorderOn
{
Winset, Alwaysontop, Off , %WinTitle%
BorderOn := False
SetTimer, DrawRect, Off
Gui, guiborder: Cancel
}
Else
{
MouseGetPos,,, WinID
WinTitle = ahk_id %WinID%
Winset, Alwaysontop, On , %WinTitle%
BorderOn := True
SetTimer, DrawRect, 50
border_thickness = 5
border_color = FF0000
}
Return
screenshot
pinanddrawrect.7z
(886 Bytes, 下载次数: 18)
|