7 posts in this topic
I have a script that gets a list of visible windows and makes a tray item of each in the tray menu. I'd also want it to update every time I want to access that menu again, in case new windows have appeared or some would have been closed. I'm using TrayOnEventMode option and trying to get the update going with TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN...) as in the snippet below. However, the list doesn't update until after the tray menu has been closed again. I think I could work around this by having the script update the list constantly in the background, but that feels like it'd take up unnecessary amount of resources since the script might be used rarely by the user anyway. I tried using TraySetOnEvent($TRAY_EVENT_MOUSEOVER...), and that kind of does it, but it actually still calls my function many times (since the mouse cursor moves quite a bit on the icon) before the tray menu is opened. I could put another menuitem to call the update function, but I'd much rather have just the minimal amount of user actions. Similarly I could have tray menu open with a double click (with TraySetClick()) and have the first click just call the update function, but can anyone tell me if there's a way to call the update once and then have the menu open without these gimmicks?
Opt("TrayOnEventMode", 1) TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "UpdateWindowsList")
I have a custom icon for the tray menu icon, which was working until I copied in the example code for a custom menu when clicking on the tray icon, now it just displays the default AutoIt tray icon. The menu works fine, but the tray icon initiates as the AutoIt default icon and the icon won't change on event.
Can anyone advise what I need to do to use my custom icon while retaining the tray custom menu?
Also, the While 1 ... WEnd makes me nervous, how does this not lock up the system? If anyone would like to comment on that - thanks.
Opt("TrayMenuMode", 3) #include <TrayConstants.au3> Local $idAbout = TrayCreateItem("About") Local $idExit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) While 1 Switch TrayGetMsg() Case $idAbout MsgBox(1,"test","test msg") Case $idExit Exit EndSwitch WEnd If Not FileExists (@TempDir & "\MyIcons") Then DirCreate(@TempDir & "\MyIcons") FileInstall(".\Grey-1.ico", @TempDir & "\MyIcons\Grey-1.ico", 1) FileInstall(".\Yellow-1.ico", @TempDir & "\MyIcons\Yellow-1.ico", 1) TraySetIcon(@TempDir & "\MyIcons\Grey-1.ico");Change icon to grey initially ; If X happens then change tray icon to yellow ; If Y happens then change tray icon to grey
My problem is split in two, so I'll start with the first one:
What I'm having is my script with dynamically created GUIs with similar / identical names. I would like to have that undepending on how many windows I have open to only have one "window" down at the taskbar.
I guess all I need is the correct GUI style, but I can't find which one I need.
Which brings me to problem part 2 (which I also find to be the easy part):
Windows will open and close on random, so there's no set order in which they'll get closed. But I still need one "window" at the taskbar to work with as long as there's at least one window open.
In the action of one of these windows getting minimized/restored all of the windows will act simultaneously.
This will be solved with something similar:
case $GUI_EVENT_MINIMIZE for $1 = 1 to Ubound($ActiveWindows) step +1 WinSetState($ActiveWindows[$1], @SW_MINIMIZE) Next And vice versa for restore.
So .. Mainly prob #1 that I need some help with, and a thought about the "always one window at taskbar"-issue.
Just point me in the right direction and I'll hopefully solve it myself ^__^'
Thanks, and have a great weekend!
Hi! Please, give me script that would hide all tray icons which appear when the script is working.
Here is an UDF to create, delete, set the icon and state, tooltip and tip for your notify icons.
The main advantage is that you can handle mouse events as you want, there is no default events.
You can create fully customised notifyicons/tooltips.
Thanks to Holger Kotsch for his ModernMenu UDF.
Breaking changes ! Please use the 1.2+ version.
Example + UDF :
AutoIt v126.96.36.199+ NotifyIcon_1.2.zip
AutoIt v188.8.131.52+ TrayIconEx.zip & Requirements : >WinAPIEx UDF.
As usual, enjoy !