ZoScr Posted July 2, 2006 Posted July 2, 2006 My script has a tray icon, with tray menu items. I'd like a global hotkey to bring up this menu. Can I do this? Should it be done via somehow clicking the tray icon (I have tried but failed to figure out how to do this), or should I instead just forget this approach and instead have the hotkey popup a new window with a menu? Thanks in advance...
nfwu Posted July 2, 2006 Posted July 2, 2006 Maybe somehow sending a $TRAY_EVENT_PRIMARYDOUBLE to the Tray Icon? #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode()
Holger Posted July 2, 2006 Posted July 2, 2006 Sample script for showing the traymenu somewhere: expandcollapse popup#include <Constants.au3> Opt("TrayMenuMode", 1) Opt("WinTitleMatchMode", 4) Global Const $TPM_BOTTOMALIGN = 0x0020 $aboutItem = TrayCreateItem("About") TrayCreateItem("") $exitItem = TrayCreateItem("Exit") HotKeySet("^!t", "ShowTrayMenu") ; Ctrl + Alt + t While 1 $Msg = TrayGetMsg() Switch $Msg Case $exitItem ExitLoop Case $aboutItem Msgbox(0, "Info", "Just for fun...") EndSwitch WEnd Exit Func ShowTrayMenu() Local $stPoint = DllStructCreate("int;int") DllCall("user32.dll", "int", "GetCursorPos", _ "ptr", DllStructGetPtr($stPoint)) DllCall("user32.dll", "int", "TrackPopupMenuEx", _ "hwnd", TrayItemGetHandle(0), _ "int", $TPM_BOTTOMALIGN, _ "int", DllStructGetData($stPoint, 1), _ "int", DllStructGetData($stPoint, 2), _ "hwnd", WinGetHandle("classname=AutoIt v3"), _ "ptr", 0) EndFunc Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
Holger Posted July 2, 2006 Posted July 2, 2006 2nd possibility: #include <Constants.au3> Opt("TrayMenuMode", 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 ExitLoop Case $aboutItem Msgbox(0, "Info", "Just for fun...") EndSwitch WEnd Exit Func ShowTrayMenu() DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle("classname=AutoIt v3"), _ "int", $MY_WM_NOTIFYICON, _ "int", 0, _ "int", $WM_LBUTTONDOWN) EndFunc Greets Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
ZoScr Posted July 3, 2006 Author Posted July 3, 2006 2nd possibility: Global Const $WM_USER = 0x0400 Global Const $MY_WM_NOTIFYICON = $WM_USER + 1 Global Const $WM_LBUTTONDOWN = 0x0201Interesting suggestion, Holger! How about if I need to double click the tray icon (as may be the case for a non-AutoIt application's tray menu)? Thanks!
dandymcgee Posted August 18, 2006 Posted August 18, 2006 Whenever I try to use $TRAY_EVENT_PRIMARYDOUBLE, it says variable used without being specified. I've searched through all of the included .au3 files that came with autoit, and found no traces of any of the TRAY_EVENT functions. ANY IDEAS???? - Dan [Website]
amin84 Posted September 1, 2019 Posted September 1, 2019 (edited) On 7/2/2006 at 9:00 AM, Holger said: #include <Constants.au3> Opt("TrayMenuMode", 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 ExitLoop Case $aboutItem Msgbox(0, "Info", "Just for fun...") EndSwitch WEnd Exit Func ShowTrayMenu() DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle("classname=AutoIt v3"), _ "int", $MY_WM_NOTIFYICON, _ "int", 0, _ "int", $WM_LBUTTONDOWN) EndFunc When I run this, and use the hotkey, it first shows Script Paused and Exit menu then when I click Exit, then the next time, it shows About and Exit menu. Shouldn't it just show the About and Exit from the beginning? Edited September 1, 2019 by leomoon
Nine Posted September 1, 2019 Posted September 1, 2019 @leomoon It seems related to Scite. If you run this code without Scite, you will see it works nicely. I do not know if this can be called a bug or not ? Maybe @Jos can tell us. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Developers Jos Posted September 1, 2019 Developers Posted September 1, 2019 (edited) 43 minutes ago, Nine said: Maybe @Jos can tell us. Are you using the full SciTE4AutoIt3 version? I assume this is because SciTE4AutoIt3 will run AutoIt3Wrapper with AutoIt3, and it in turn will shell an extra watchdog version of Autoit3Wrapper to monitor whether one wants to kill the running script via SciTE and process are still running. At first run you can see that one of the 3 AutoIt3 background processes gets killed although nothing visual happens, so assume the watchdog process gets killed. Jos edit: Try this version #include <Constants.au3> AutoItWinSetTitle("demotraymenu") Opt("TrayMenuMode", 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 ExitLoop Case $aboutItem MsgBox(0, "Info", "Just for fun...") EndSwitch WEnd Exit Func ShowTrayMenu() DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle("demotraymenu"), _ "int", $MY_WM_NOTIFYICON, _ "int", 0, _ "int", $WM_LBUTTONDOWN) EndFunc ;==>ShowTrayMenu Edited September 1, 2019 by Jos added fix for example Nine 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Nine Posted September 1, 2019 Posted September 1, 2019 Well see @Jos, it was actually the wrapper that was killed first...Just changing title do the trick. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
amin84 Posted September 1, 2019 Posted September 1, 2019 (edited) Wow that was very hard to detect! Thanks for the fix. So I stumbled upon this script to see if I can get the handle of active window then show a menu (to change size and other properties of that active window). I tried adding WinGetHandle just before the DllCall in the ShowTrayMenu() but I only get 0x0000000000000000: Func ShowTrayMenu() ConsoleWrite(WinGetHandle('')&@LF) DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle("demotraymenu"), _ "int", $MY_WM_NOTIFYICON, _ "int", 0, _ "int", $WM_LBUTTONDOWN) EndFunc This script is kinda hard to understand! Edited September 1, 2019 by leomoon
Nine Posted September 1, 2019 Posted September 1, 2019 You can now use instead of the dllcall : _SendMessage(WinGetHandle("demotraymenu"), $MY_WM_NOTIFYICON, 0, $WM_LBUTTONDOWN) Just add #include <SendMessage.au3> at the beginning of the script. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
amin84 Posted September 2, 2019 Posted September 2, 2019 I didn't know about _SendMessage. Very useful. Perfect. Thank you.
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