[AHK V2]鼠标悬停展开窗口,鼠标离开折叠窗口

演示鼠标悬停窗口标题栏则展开窗口,鼠标离开窗口标题栏则折叠窗口。

javascript 复制代码
;作者:sunwind
;日期:2024年6月30日11:36:08
;脚本:演示鼠标悬停窗口标题栏则展开窗口,鼠标离开窗口标题栏则折叠窗口。
MyGui := Gui()
mytext:=MyGui.Add("Text",, "Please enter your name:")
MyGui.AddEdit("vName")
MyGui.always:=0
MyGui.mode:="折叠"
MyGui.Title:="悬停展开,离开折叠"
MyGui.OnEvent("Close", myGui_Close)
myGui_Close(thisGui) {  ; 声明中 this 参数是可选的.
    if MsgBox("Are you sure you want to close the GUI?",, "y/n") = "No"
        return true  ; true = 1
    else
        {
         MyGui.Destroy 
         ExitApp
        }
}
MyGui.Show("w300 h1")
OnMessage( WM_MOUSEMOVE := 0xA0, onNcMouseMove  )
OnMessage( WM_NCMOUSELEAVE := 0x2A2,  onNcMouseLeave)

onNcMouseMove(wParam, lParam, msg, hwnd) {
    if  (MyGui.mode="折叠")
        {
            OutputDebug "折叠->展开"
            WinMove , ,300,200, MyGui.Title
            MyGui.mode:="展开"
        }
    }

onNcMouseLeave(wParam, lParam, msg, hwnd) {
    if  (MyGui.mode="展开" and MyGui.always!=1)
        {
            OutputDebug "展开->折叠"
            try
                {
                    WinMove , ,300,28, MyGui.Title 
                    MyGui.mode:="折叠"
                }  
        }
}
#HotIf overTitleBar()
RButton::
{
    ; OutputDebug overTitleBar()
    MyGui.always:= !MyGui.always
    if(MyGui.always)
        {
            try
                {
                    WinMove , ,300,200, MyGui.Title
                    ToolTip "持续展开"
                }
        }
    Else
        {
            ToolTip "鼠标悬停展开"
        }
    SetTimer(ToolTip,-1000)
} 
#HotIf

overTitleBar() { 
    ; https://www.autohotkey.com/boards/viewtopic.php?t=31119
    CoordMode("Mouse")
    MouseGetPos(&x, &y, &hWnd)
    ErrorLevel := SendMessage(WM_NCHITTEST := 0x84, 0, x | y << 16, , "ahk_id " hWnd)
    Return (ErrorLevel = HTCAPTION := 2) and (hWnd=MyGui.Hwnd)
   }
相关推荐
小Mie不吃饭2 个月前
AHK是让任何软件都支持 Shift + 鼠标滚轮 实现界面水平滚动
vscode·sublime text·记事本·autohotkey·shift+滚轮·水平滚动·高效快捷
也好先生2 个月前
AutoHotKey自动热键(十一)下载SciTE4AutoHotkey-Plus的中文增强版脚本编辑器
自动化·编辑器·计算机外设·快捷键·autohotkey·windows热键
liuyukuan2 个月前
[AHK] WinHttpRequest.5.1报错 0x80092004 找不到对象或属性
winhttprequest·autohotkey·0x80092004
也好先生2 个月前
AutoHotKey自动热键(七)WINDOWS按键映射与鼠标映射(替换/组合)
自动化·计算机外设·快捷键·autohotkey·windows热键·脚本热键·鼠标键盘映射
liuyukuan2 个月前
[AHK V2]SQLite测试用例
数据库·sqlite·ahk·autohotkey
也好先生2 个月前
AutoHotKey自动热键(二)中文版帮助手册下载和自定义一般键盘快捷键
计算机外设·autohotkey
飞跃-2 个月前
AHK的对象和类学习心得
autohotkey
liuyukuan5 个月前
【AHK v2】数据结构LinkedList实现示例
数据结构·ahk·autohotkey·v2
liuyukuan9 个月前
[AHK]一键调用office365的“放置在单元格中”功能
ahk