右击托盘图标 Topic is solved
Moderators: tmplinshi, arcticir
Re: 右击托盘图标
您好,这样改了一下,但是会报错,不知哪里有误。
Code: Select all
; Function .....: TrayIcon_Button
; Description ..: Simulate mouse button click on a tray icon.
; Parameters ...: sExeName - Executable Process Name of tray icon.
; ..............: sButton - Mouse button to simulate (L, M, R).
; ..............: bDouble - True to double click, false to single click.
; ..............: nIdx - Index of tray icon to click if more than one match.
; ----------------------------------------------------------------------------------------------------------------------
TrayIcon_Button(Shadowsocks, sButton:="R", bDouble:=False, nIdx:=1)
{
d := A_DetectHiddenWindows
DetectHiddenWindows, On
WM_MOUSEMOVE = 0x0200
WM_LBUTTONDOWN = 0x0201
WM_LBUTTONUP = 0x0202
WM_LBUTTONDBLCLK = 0x0203
WM_RBUTTONDOWN = 0x0204
WM_RBUTTONUP = 0x0205
WM_RBUTTONDBLCLK = 0x0206
WM_MBUTTONDOWN = 0x0207
WM_MBUTTONUP = 0x0208
WM_MBUTTONDBLCLK = 0x0209
sButton := "R"
oIcons := TrayIcon_GetInfo(Shadowsocks)
If ( bDouble )
PostMessage, oIcons[nIdx].msgid, oIcons[nIdx].uid, %sButton%DBLCLK,, % "ahk_id " oIcons[nIdx].hwnd
Else
{
PostMessage, oIcons[nIdx].msgid, oIcons[nIdx].uid, %sButton%DOWN,, % "ahk_id " oIcons[nIdx].hwnd
PostMessage, oIcons[nIdx].msgid, oIcons[nIdx].uid, %sButton%UP,, % "ahk_id " oIcons[nIdx].hwnd
}
DetectHiddenWindows, %d%
Return
Re: 右击托盘图标
As @tmplinshi (the author of these functions) is a moderator of this forum section (and therefore should speak your native language), I'd guess he'll be able to give you some advice on this. Good luck
Re: 右击托盘图标
你好,
你需要调用 TrayIcon_Button 这个函数, 而不是去修改它.
点击弹出的右键菜单可参考这个脚本:
https://github.com/tmplinshi/RegSsHotkey/blob/master/Lib/RegisterShadowsocksHotkey.ahk
你需要调用 TrayIcon_Button 这个函数, 而不是去修改它.
Code: Select all
#Include TrayIcon.ahk ; 或者完整路径 D:\Desktop\TrayIcon.ahk
TrayIcon_Button("Shadowsocks.exe", "R")
https://github.com/tmplinshi/RegSsHotkey/blob/master/Lib/RegisterShadowsocksHotkey.ahk
Re: 右击托盘图标
谢谢!tmplinshi wrote: ↑10 Jun 2020, 07:44你好,
你需要调用 TrayIcon_Button 这个函数, 而不是去修改它.
点击弹出的右键菜单可参考这个脚本:Code: Select all
#Include TrayIcon.ahk ; 或者完整路径 D:\Desktop\TrayIcon.ahk TrayIcon_Button("Shadowsocks.exe", "R")
https://github.com/tmplinshi/RegSsHotkey/blob/master/Lib/RegisterShadowsocksHotkey.ahk