托盘图标鼠标按键触发更改

; 以下示例效果为:左键单击显示托盘菜单/禁止右键单击菜单

#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
}

给TA捐赠
共{{data.count}}人
人已捐赠
其他教程

指定窗口不会被最小化和窗口坐标归位

2021-11-24 8:58:45

其他函数教程

【函数】利用ACC和UIA后台获取文本 By FeiYue

2021-11-24 8:59:13

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
有新私信 私信列表
搜索