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

55 篇文章 6 订阅

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

;作者: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)
   }

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值