legend Posted April 19, 2018 Posted April 19, 2018 (edited) #include <Constants.au3> Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) Opt("WinTitleMatchMode", 4) Global Const $WM_USER = 0x0400 Global Const $MY_WM_NOTIFYICON = $WM_USER + 1 Global Const $WM_LBUTTONDOWN = 0x0201 $aboutItem = TrayCreateItem("About") TrayCreateItem("") $exitItem = TrayCreateItem("Exit") HotKeySet("t", "ShowTrayMenu") ; Ctrl + Alt + t While 1 $Msg = TrayGetMsg() Switch $Msg Case $exitItem Exit Case $aboutItem Msgbox(0, "Info", "Just for fun...") EndSwitch WEnd Func ShowTrayMenu() DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle("classname=AutoIt v3"), "int", $MY_WM_NOTIFYICON, "int", 0, "int", $WM_LBUTTONDOWN) EndFunc I have this code that will show the traymenu near the mouse when you click "t". (compile it and run it and click t). Now the thing is, if i have another compiled autoit script running, it will no longer show the traymenu, instead it will show: I thought I would solve the issue if I changed the classname "AutoIt v3 GUI", but that didn't solve it: https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_RegisterClassEx.htm Edited April 19, 2018 by legend
InnI Posted April 19, 2018 Posted April 19, 2018 You can use some unique title for AutoIt window ... $title = _WinAPI_CreateGUID() AutoItWinSetTitle($title) ... Func ShowTrayMenu() DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($title), "int", $MY_WM_NOTIFYICON, "int", 0, "int", $WM_LBUTTONDOWN) EndFunc
legend Posted April 19, 2018 Author Posted April 19, 2018 1 hour ago, InnI said: You can use some unique title for AutoIt window ... $title = _WinAPI_CreateGUID() AutoItWinSetTitle($title) ... Func ShowTrayMenu() DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($title), "int", $MY_WM_NOTIFYICON, "int", 0, "int", $WM_LBUTTONDOWN) EndFunc Thanks a lot lnnl learned something new, I didn't new those 2 commands, it works perfectly
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now