V2 用户的话,推荐用 H 版,AutoHotkey 的最富集,兼容 L 版
EdgeHiding(hwnd, to := 1) {
if InStr('|Progman|Shell_TrayWnd|WorkerW|', '|' WinGetClass(hwnd) '|')
return
if id := DllCall('FindWindowW', "ptr", 0, "str", 'EdgeHiding_' hwnd, "ptr")
return SendMessage(40400, , , , id)
if DllCall("IsZoomed", "ptr", hwnd)
{
WinRestore hwnd
Sleep 20
}
WinGetPos &x, &y, &w, &h, hwnd
b := SysGet(4)
switch to ;1下 ,2左, 3上, 4右
{
case 1:
mx := x
my := A_ScreenHeight - h
ax := x
ay := A_ScreenHeight - 2
aw := w
ah := 2
case 2:
mx := 0
my := y
ax := -20
ay := y
aw := 22
ah := h - b
case 3:
mx := x
my := -20
ax := x
ay := 0
aw := w
ah := 22
default:
mx := A_ScreenWidth - w
my := y
ax := A_ScreenWidth - 1
ay := y
aw := 1
ah := h - b
}
WinMove mx, my, , , hwnd
ui := Gui('+Owner' hwnd ' -Caption AlwaysOnTop +ToolWindow +E0x8000000', 'EdgeHiding_' hwnd)
ui.exsty := DllCall("GetWindowLongW", "ptr", hwnd, "int", -20, "int")
ui.sty := DllCall("GetWindowLongW", "ptr", hwnd, "int", -16, "int")
WinSetAlwaysOnTop 1, hwnd
WinHide hwnd
WinSetStyle -0xC00000, hwnd ; 隐藏标题栏
;WinSetExStyle +0x80, hwnd ;隐藏三按钮
;WinSetStyle +0x80000000, hwnd ;弹窗模式,特点是无边框
ui.show("NoActivate x" ax " y" ay " w" aw " h" ah)
WinSetTransparent 1, ui.hwnd
ui.OnMessage(0x200, EdgeHiding_show)
ui.OnMessage(40400, EdgeHiding_destroy)
ui.win := hwnd
ui.x := x
ui.y := y
}
EdgeHiding_destroy(ui, *) {
ui.de := 1
WinActivate ui.hwnd
Sleep 20
;WinSetExStyle -0x80, ui.win
;WinSetStyle -0x80000000, ui.win
WinSetStyle +0xC00000, ui.win
DllCall("SetWindowLongW", "ptr", ui.win, "int", -20, "int", ui.exsty)
DllCall("SetWindowLongW", "ptr", ui.win, "int", -16, "int", ui.sty)
WinSetAlwaysOnTop 0, ui.win
WinShow ui.win
WinMove ui.x, ui.y, , , ui.win
WinActivate ui.win
ui.destroy()
}
EdgeHiding_show(ui, *) {
ui.OnMessage(0x200, EdgeHiding_show, 0)
ui.Hide()
if !WinExist(ui.win)
return SendMessage(40400, , , , ui.hwnd)
WinShow ui.win
WinActivate ui.win
WinWaitNotActive ui.win
if ui.HasOwnProp('de')
return
if !WinExist(ui.win)
return SendMessage(40400, , , , ui.hwnd)
WinHide ui.win
ui.show('NoActivate')
ui.OnMessage(0x200, EdgeHiding_show)
}