这段代码使用 AutoHotkey (AHK) 实现了一个小型窗口展示功能,同时利用自定义函数 WinMoveZ 确保窗口在屏幕边界内移动或显示。窗口展示了一段文字,并被放置到屏幕右下角的边缘位置。

 

; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=76745
#SingleInstance, Force
Gui, New, -Caption +Border +AlwaysOnTop +Disabled +Owner +hWndhWnd
Gui, Font, s20, Segoe UI
Gui, Add, Text,, Hello World !
Gui, Show, Hide
DetectHiddenWindows, On
WinGetPos, X, Y, W, H, ahk_id %hWnd%
WinMoveZ(hWnd, 0, A_ScreenWidth-1, A_ScreenHeight-1, W, H)
DetectHiddenWindows, Off
Gui, Show, NA
Return

WinMoveZ(hWnd, C, X, Y, W, H, Redraw:=0) { ;  WinMoveZ v0.5 by SKAN on D35V/D361 @ tiny.cc/winmovez 
Local V:=VarSetCapacity(R,48,0), A:=&R+16, S:=&R+24, E:=&R, NR:=&R+32, TPM_WORKAREA:=0x10000
  C:=( C:=Abs(C) ) ? DllCall("SetRect", "Ptr",&R, "Int",X-C, "Int",Y-C, "Int",X+C, "Int",Y+C) : 0
  DllCall("SetRect", "Ptr",&R+16, "Int",X, "Int",Y, "Int",W, "Int",H)
  DllCall("CalculatePopupWindowPosition", "Ptr",A, "Ptr",S, "UInt",TPM_WORKAREA, "Ptr",E, "Ptr",NR)
  X:=NumGet(NR+0,"Int"),  Y:=NumGet(NR+4,"Int")
Return DllCall("MoveWindow", "Ptr",hWnd, "Int",X, "Int",Y, "Int",W, "Int",H, "Int",Redraw)
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。