RiseUp wrote:
If it appears in Task Manager as java.exe, then surely that could be the issue. Also, the uncommented call to the library function in your code simulates a single-click with the left mouse button. Is that what you're trying for?

Using TrayIcon_GetInfo() would definitely help to debug your issue, but it isn't necessary to get it working once you have the right parameter(s) figured out for TrayIcon_Button().

Thank you very much for the code! I ran the script and five of twelve SysTray icons are listed - and the java one is missing amongst others. I guess that's the point, where my endeavour comes to an abrupt end?

Maybe there will be a "universal" version of TrayIcon, which would a) display visible and hidden icons and b) deliver information about the state of visibility in the future - I will try it again, as soon as I get all my SysTray icons listed.

it would also be cool, if the system icons like network connection, battery, sound, language and clock would be clickable as well.

Vince42 wrote:Maybe there will be a "universal" version of TrayIcon, which would a) display visible and hidden icons and b) deliver information about the state of visibility in the future - I will try it again, as soon as I get all my SysTray icons listed.

it would also be cool, if the system icons like network connection, battery, sound, language and clock would be clickable as well.

I've made a change to the library's code and put it up on Github, but I'll post it here, too:

Hopefully, this should work for both the hidden and the visible tray icons. Once you have the newest TrayIcon.ahk in one of your library locations, try this code that should list all of your tray icons, both visible and hidden:

My first attempt at fixing this for Windows 10 was something of a hack that only worked mostly by accident. Your solution of just looping again works but is kind of a hack to in that basically in Windows 10 you want ToolbarWindow323 for the Shell_TrayWnd.

I did a hack of checking Windows version and trying to if-then the right ToolbarWindow32?.

Windows seems to just keep making ToolbarWindow32 and putting a number on the end as needed, so even looping to 3 is no guarantee to continue working. The Shell_TrayWnd is not always 3.

I took what is hopefully a better approach and modified the function TrayIcon_GetTrayBar which all along was supposed to be the function to get the correct number before Windows introduced the NotifyIconOverflowWindow.

Maybe someone will find it useful although there is not really a definitive TrayIcon.ahk update from the original work Sean.

SquirrelHugger wrote:EDIT: well it worked when I tried to double click another tray icon, but not for qbittorrent.exe
Any idea why?

The reason some tray icons work and others do not probably has to do with permissions. Some tray icons are probably running as a higher-privileged process that basically don't want to be messed with by a lower-privileged process. The function uses a PostMessage to tell the program its tray icon has been clicked but PostMessage could be used to control the program in lots of other ways which the program does not want without the right permissions.

It is probably more complicated than just running your script as an administrator. There are probably ways to get around it but I am no expert on User Account Control and User Interface Privilege Isolation. The function is actually pretty simple and small but the code to get around the permissions is probably going to be much more complicated and long.

My first attempt at fixing this for Windows 10 was something of a hack that only worked mostly by accident. Your solution of just looping again works but is kind of a hack to in that basically in Windows 10 you want ToolbarWindow323 for the Shell_TrayWnd.

I did a hack of checking Windows version and trying to if-then the right ToolbarWindow32?.

Windows seems to just keep making ToolbarWindow32 and putting a number on the end as needed, so even looping to 3 is no guarantee to continue working. The Shell_TrayWnd is not always 3.

I took what is hopefully a better approach and modified the function TrayIcon_GetTrayBar which all along was supposed to be the function to get the correct number before Windows introduced the NotifyIconOverflowWindow.

Maybe someone will find it useful although there is not really a definitive TrayIcon.ahk update from the original work Sean.

FG

Thank you for your additional fixes, as well as your explanation of the theory behind them.