检测托盘气泡的点击

许多实用脚本和封装函数, 可以让您编写脚本更加便捷高效

Moderators: tmplinshi, arcticir

tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

检测托盘气泡的点击

09 Sep 2014, 10:06

不是我写的。在这个帖子 http://www.autohotkey.com/board/topic/6 ... /?p=408503 找到的。

Code: Select all

TrayTip, AutoHotkey, Click Me, 10
Return

; 检测托盘气泡的点击
TB_HIDEBUTTON(wParam, lParam, msg, hwnd) {
	static WM_USER := 0x400
	static _______ := OnMessage(WM_USER + 4, "TB_HIDEBUTTON")
	
	If (lParam = 1029)
	{
		MsgBox TrayTip Click`, AutoHotkey will now exit
		ExitApp
	}
}
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: 检测托盘气泡的点击

09 Sep 2014, 20:21

嗯,实用。
  • 更好奇WM_USER+4中4,及lParam = 1029怎么来的。
    监视消息?有无完整可用消息列表呢..
  • static来自动初始化挺好(在 定义中亦可),是你改造的吧..于类初始化时执行函数 - 代码初始化顺序(AHK8帖子)
  • 能合并到气泡主题相关内容就好了。
我为人人,人人为己?
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: 检测托盘气泡的点击

10 Sep 2014, 04:39

搜索了一下这个lParam:
http://www.kmonos.net/repos/qbga32/ci/c2b7a98c21?sbs=0 wrote:+// #if (_WIN32_IE >= 0x0501)
+enum : uint { NIN_BALLOONSHOW = WM_USER + 2 }
+enum : uint { NIN_BALLOONHIDE = WM_USER + 3 }
+enum : uint { NIN_BALLOONTIMEOUT = WM_USER + 4 }
+enum : uint { NIN_BALLOONUSERCLICK = WM_USER + 5 }
+// #endif
加个 ToolTip 可以看到其他有意思的 lParam 参数:

Code: Select all

TrayTip, AutoHotkey, Click Me, 10
Return

; 检测托盘气泡的点击
TB_HIDEBUTTON(wParam, lParam, msg, hwnd) {
    static WM_USER := 0x400
    static _______ := OnMessage(WM_USER + 4, "TB_HIDEBUTTON")
    
    static log
    ToolTip, % ( log .= lParam "`n" )
    
    If (lParam = 1029)
    {
        MsgBox TrayTip Click`, AutoHotkey will now exit
        ExitApp
    }
}
http://bbs.csdn.net/topics/90141544#post-62799961 wrote:Integer WM_LBUTTONDOWN = 513 // 在托盘图标点击左键
Integer WM_RBUTTONDOWN = 516 // 在托盘图标点击右键
Integer WM_MBUTTONDOWN = 519 // 在托盘图标点击中键
Integer NIN_BALLOONSHOW = 1026 //当 Balloon Tips 弹出
Integer NIN_BALLOONHIDE = 1027 //当 Balloon Tips 消失(如 SysTrayIcon 被删除),但指定的 TimeOut 时间到或鼠标点击 Balloon Tips 后的消失不发送此消息
Integer NIN_BALLOONTIMEOUT = 1028 // 当 Balloon Tips 的 TimeOut 时间到
Integer NIN_BALLOONUSERCLICK = 1029 //当鼠标点击 Balloon Tips
//注意:在XP下执行时 Balloon Tips 上有个关闭按钮,
//如果鼠标点在按钮上将接收到 NIN_BALLOONTIMEOUT 消息。
static _______ := OnMessage(WM_USER + 4, "TB_HIDEBUTTON") 这样的写法方便多了,OnMessage 跟函数分两个地方写太麻烦。
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: 检测托盘气泡的点击

10 Sep 2014, 05:54

嗯,好用好用。

还得修正下,lParam = 1029WM_USER + 5 WM_USER即0x400/1024)

奇怪了,照说不是只能收到WM_USER + 4(5)吗,但确实出现了好些其他记录...
又发现Bug了吗?好像拿去骚扰lexikos。
Last edited by RobertL on 13 Sep 2014, 07:46, edited 1 time in total.
我为人人,人人为己?
User avatar
huyaowen
Posts: 109
Joined: 28 Jul 2014, 01:15

Re: 检测托盘气泡的点击

13 Sep 2014, 07:34

牛,感谢,正有用

Return to “脚本函数”

Who is online

Users browsing this forum: No registered users and 7 guests