All Things WinBatch > WinBatch

IntControl 1007 - Tray icon randomly disappears from systray

(1/2) > >>

I have a swiss-army-knife desktop app that runs in the background and monitors a bunch of stuff, lets me show/hide windows, etc.

I use IntControl 1007 to display a tray icon that controls the app, using MegaPop (many thanks to IFICantBYTE - it works brilliantly!) to provide a pop-up menu from the tray icon.

The tray icon should always be present if the app is running, only disappearing when told to do so on app close.

However, from time to time the tray icon just disappears (it is not being moved to the "hidden icons" in the systray, it is truly gone).

It would be great to have a p1 value for IntControl 1007 that queries the tray icon's status (present/absent) and allows me to only refresh the tray icon if it is missing. Without that, though, are there any thoughts on how to best manage the situation?

I've just now added a call in the app's main loop that re-writes the tooltip each loop, but I won't know for several weeks (or months) if that "did the trick" or not.

I guess my question is: if the tray icon has disappeared and I refresh the tooltip, will that cause the tray icon to reappear in the systray?  (I realize this might be a "nobody knows" situation since this is a rather esoteric question, but am asking in case someone has encountered it before).

Or does anyone else have a better idea re how to solve this situation?  Is there maybe a DLL call that can be made to check the state of the tray icon?

I am using WB 2018 B.

You should have also mentioned your Windows version, e.g., Windows 10 1809. 

Often, when a non-windows provided system tray Icon disappears it is because the Windows Shell has silently crashed and restarted.  If that is the case, you will need to figure out what is causing your shell to occasionally crash.  That can be difficult because the OS automatically restarts the shell after a crash and it can all happen in an imperceptible instant.

Ahhhh... very useful to know.  I also note that occasionally Google Chrome instances will disappear from the taskbar - I need to cycle explorer.exe and they re-appear. Perhaps a mini OS crash is what is causing both problems. Still,  after cycling explorer.exe I've never seen a disappeared tray icon re-appear, and never observed any connection between a missing trayicon and missing Google Chrome taskbar instances.

Any further thoughts about querying the visibility of the tray icon?

I am using Win7 HP.

The behavior is a function of the way the Windows Shell is "designed" to work on your version of Windows.  On Windows 10 1903 you simply need to install a shortcut for your script/application in the shell's startup directory and it will usually reconnect to the system tray when Explorer restarts.  However, I am not sure that this is the case on Windows 7.  (How quickly I forget the details of old versions of Windows...)

Anyway,  you can find the shell's startup location by simply calling dirStartup =ShortCutDir("Common Startup", 1,1) to get the startup folder for all users. On Windows 10 this is normally the "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\" directory on the file system.  Again, not sure if this will solve the problem on Windows 7.

Yes, I already am starting the app from a shortcut stored in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

Either Win7 is not automatically re-connnecting the icon to the system tray, or the problem is summat else.

I'll wait and see if refreshing the tooltip associated to the tray icon does the trick, and if not, I'll try the more heavy-handed method of removing/reinstalling the tray icon with each loop. I suspect, though, that the regular disappear/reappear of the tray ICON will be more annoying that my current workaround of manually dropping a trigger file into the app folder whenever I see the tray icon is missing.


[0] Message Index

[#] Next page

Go to full version