; 以下示例效果为:左键单击显示托盘菜单/禁止右键单击菜单
#SingleInstance, Force
Return ; end of auto-execute section
NotifyTrayClick_202: ; Left click (Button up)
Menu, Tray, Show
Return
NotifyTrayClick_205: ; Right click (Button up)
Return ; Supress right click menu
; 鼠标中键点击托盘图标查看剪贴板内容
/*
#NoEnv
SendMode Input
#Persistent
#SingleInstance Force
#InstallMousehook
Return
NotifyTrayClick_207: ; middle click (Button down)
gui, add,text,, %clipboard%
gui, show
keywait, mbutton
gui, destroy
return
*/
; AHK托盘内容进行删减
/*
#NoEnv
#SingleInstance, Force
#Persistent
hMenu := MenuGetHandle("Tray")
DllCall("RemoveMenu", "Ptr",hMenu, "Int",65300, "Int",0 ) ; Open
DllCall("RemoveMenu", "Ptr",hMenu, "Int",65301, "Int",0 ) ; Help
DllCall("RemoveMenu", "Ptr",hMenu, "Int",65308, "Int",0 ) ; Seperator
DllCall("RemoveMenu", "Ptr",hMenu, "Int",65302, "Int",0 ) ; Window Spy
;DllCall("RemoveMenu", "Ptr",hMenu, "Int",65303, "Int",0 ) ; Reload the script
;DllCall("RemoveMenu", "Ptr",hMenu, "Int",65304, "Int",0 ) ; Edit this script
;DllCall("RemoveMenu", "Ptr",hMenu, "Int",65305, "Int",0 ) ; Suspend Hotkeys
;DllCall("RemoveMenu", "Ptr",hMenu, "Int",65306, "Int",0 ) ; Pause script
;DllCall("RemoveMenu", "Ptr",hMenu, "Int",65309, "Int",0 ) ; Seperator
;DllCall("RemoveMenu", "Ptr",hMenu, "Int",65307, "Int",0 ) ; Exit
Return
*/
; AHK显示点击触发托盘的按键名
/*
#NoEnv
#SingleInstance, Force
Menu, Tray, Tip, Menu not available`n Use Close button to Exit this APP
WM := {0x201:"WM_LBUTTONDOWN", 0x202:"WM_LBUTTONUP", 0x203:"WM_LBUTTONDBLCLK"
, 0x204:"WM_RBUTTONDOWN", 0x205:"WM_RBUTTONUP", 0x206:"WM_RBUTTONDBLCLK"
, 0x207:"WM_MBUTTONDOWN", 0x208:"WM_MBUTTONUP", 0x209:"WM_MBUTTONDBLCLK"}
Gui, NTC_:New, +ToolWindow +AlwaysOnTop, NotifyTrayClick() - History
Gui, Font, S10, Consolas
Gui, Add, Edit, R13 ReadOnly hWndhEdit, % Format("{:-27}", "")
GuiControl,,%hEdit%
Gui, Show, NA
NotifyTrayClick(300)
Return ; end of auto-execute section
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
`::GuiControl,,%hEdit%
NTC_GuiClose:
ExitApp
NotifyTrayClick_201: ; Left click (Button down)
NotifyTrayClick_202: ; Left click (Button up)
NotifyTrayClick_203: ; Left double click
NotifyTrayClick_204: ; Right click (Button down)
NotifyTrayClick_205: ; Right click (Button up)
NotifyTrayClick_206: ; Right double click
NotifyTrayClick_207: ; Middle click (Button down)
NotifyTrayClick_208: ; Middle click (Button up)
NotifyTrayClick_209: ; Middle double click
NM := StrReplace(A_ThisLabel, "NotifyTrayClick_", "0x")
Edit_Append(hEdit, NM . A_Tab . WM[NM] . "`r`n")
Return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Edit_Append(hEdit, Txt) { ; Modified version by SKAN
Local ; Original by TheGood on 09-Apr-2010 @ autohotkey.com/board/topic/52441-/?p=328342
L := DllCall("SendMessage", "Ptr",hEdit, "UInt",0x0E, "Ptr",0 , "Ptr",0) ; WM_GETTEXTLENGTH
DllCall("SendMessage", "Ptr",hEdit, "UInt",0xB1, "Ptr",L , "Ptr",L) ; EM_SETSEL
DllCall("SendMessage", "Ptr",hEdit, "UInt",0xC2, "Ptr",0 , "Str",Txt) ; EM_REPLACESEL
}
*/
NotifyTrayClick(P*) { ; v0.41 by SKAN on D39E/D39N @ tiny.cc/notifytrayclick
Static Msg, Fun:="NotifyTrayClick", NM:=OnMessage(0x404,Func(Fun),-1), Chk,T:=-250,Clk:=1
If ( (NM := Format(Fun . "_{:03X}", Msg := P[2])) && P.Count()<4 )
Return ( T := Max(-5000, 0-(P[1] ? Abs(P[1]) : 250)) )
Critical
If ( ( Msg<0x201 || Msg>0x209 ) || ( IsFunc(NM) || Islabel(NM) )=0 )
Return
Chk := (Fun . "_" . (Msg<=0x203 ? "203" : Msg<=0x206 ? "206" : Msg<=0x209 ? "209" : ""))
SetTimer, %NM%, % (Msg==0x203 || Msg==0x206 || Msg==0x209)
? (-1, Clk:=2) : ( Clk=2 ? ("Off", Clk:=1) : ( IsFunc(Chk) || IsLabel(Chk) ? T : -1) )
Return True
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。