WIN 10/11: Can anyone else confirm if this library works on windows 11?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ralf_Reddings200244
Posts: 110
Joined: 11 Mar 2023, 14:16

WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 08:39

I have a software that essentially breaks when its minimised to the system tray. I have no means of brining it up. I tried a bunch of things, WinActivate with DetectHiddenWindows etc etc. I eventually settled on this:

Code: Select all

If WinExist("ahk_exe transmission-qt.exe")
  WinActivate, ahk_exe transmission-qt.exe
WinWaitActive, ahk_exe transmission-qt.exe,, .1
If(ErrorLevel){
	Run, "C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile -Command "Get-Process transmission-qt | Stop-Process",, Hide
	Sleep, 200
	Run, "C:\Program Files\Transmission\transmission-qt.exe"
	WinWaitActive, ahk_exe transmission-qt.exe,, 1
}
ExitApp
Its like AHK can never find this process, when its hidden to the tray, hence why I have to call PowerShell just to kill it.

Today I realised the above solution is just terrible.
I messed around with the applications tray icon and I discovered a single click on its icon summons its window.
My issues is my taskbar is never visible so I cant simulate keyboard keys to it.

I looked around and came across this old script by Sean, TrayIcon.ahk · GitHub It promises to send Left or Right Click to tray icons.

I tested it on a number of programs hidden in the tray but nothing happens, the icons are not hidden in the tray overflow area either:

Code: Select all

TrayIcon_Button("ahk_exe Signal.exe", "L")
The above does nothing.

Can anyone else with a Windows 10/11 system, by any chance check that is also the case for them?

Thanks.
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 08:44

Use the syntax provided.

TrayIcon_Button(sExeName, sButton := "L", bDouble := false, index := 1)

There is no reference to a WinTitle here.

The library does not work for all programs, so you need to test it. Tray-based programs often have hidden windows. WinActivate is not generally used to activate a tray icon, though it might work for a small percentage of programs. For some programs, running the program will activate its window. The Process command can be helpful in meeting certain needs.
User avatar
JoeWinograd
Posts: 2214
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 11:42

Ralf_Reddings200244 wrote:Can anyone else with a Windows 10/11 system, by any chance check that is also the case for them?
Many functions of the library do not work in Windows 11 beginning with Build 22623. Here's a post at the library thread where I document it:
viewtopic.php?f=6&t=1229&start=80#p494711

In this thread, some workarounds are discussed for some of the functions:
viewtopic.php?f=76&t=111185

Here's a thread with more on it:
viewtopic.php?f=23&t=111398

That thread contains an explanation by @lexikos on why the problem is happening:
viewtopic.php?f=23&t=111398#p499459

I submitted this Feedback Hub report to Microsoft six months ago:
TB_ message calls for notification area (system tray) no longer working in Windows 11

TB_BUTTONCOUNT
TB_DELETEBUTTON
TB_GETBUTTON
TB_MOVEBUTTON

They were working fine in prior W11 releases, but do not work in Version 22H2, Build 22623.1020 (I don't know if that's the first release where they stopped working, but it's the first time that a user reported it to me). Btw, they are still working fine in W10/22H2.

Attached is VBA code that a colleague of mine wrote to show one example of the problem: TB_BUTTONCOUNT. When run on a W10/22H2 system (via Excel 365), it works fine, showing "Toolbar Buttons: 26" and "Overflow Buttons: 13". When run on a W11/22H2/22623.1020 system (also via Excel 365) with 8 icons in Shell_TrayWnd and 4 icons in NotifyIconOverflowWindow, it displays zeroes for both, i.e., "Toolbar Buttons: 0" and "Overflow Buttons: 0".

This is a critical bug that is catastrophic for several of my programs. I'd truly appreciate a fix as fast as possible.
Microsoft responded with this:
Thank you for your feedback, but what you're describing is not currently supported on Windows 11. Please file a new suggestion in the Feedback Hub if this is something you'd like us to support in the future.
They're basically saying that it's a feature, not a bug. I submitted four responses to that, including this one:
I should point out that this change in Windows 11, Version 22H2, Build 22623.1020 will break thousands of programs that rely on TB_ messages to programmatically handle the taskbar. I just counted here...it breaks at least 16 of my programs. Please reinstate the TB_ messages capability as it existed in previous W11 releases and still exists in all W10 releases.
I pointed out in another reply that the TB_BUTTONCOUNT documentation says that the minimum supported client is Windows Vista (desktop apps only), so that would certainly include W11:
https://learn.microsoft.com/en-us/windows/win32/controls/tb-buttoncount

Microsoft has not responded to any of my follow-up posts in the Feedback Hub.

I put code in all my programs to detect if the library is working (rather than checking the version of Windows) by calling TrayIcon_GetInfo() and seeing if TrayInfo.MaxIndex() (the number of icons in the tray) is non-null/non-zero. That way, I won't have to distribute new versions of my programs if and when the library starts working again.

I keep hoping that one of the library's prior authors (Sean, Cyruz, FanaticGuru) or a new player will get the library to work with the latest release of W11 (if that's even possible), as it appears that Microsoft has no intention of addressing the issue. Regards, Joe
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 12:15

Joe,

That is all very helpful and appreciated. Even earlier, success with this was not uniform, due to variations in program design, details of the tray, and so on. I mostly gave up and usually just hope that software designers will add command lines or hotkeys to toggle their windows, or that running the program will activate its window.
User avatar
JoeWinograd
Posts: 2214
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 14:04

mikeyww wrote:Even earlier, success with this was not uniform, due to variations in program design, details of the tray, and so on.
Hi mikey,
I never had problems with the library before W11/22623. Been using it in W7, W8.1, W10, W11 pre-releases, and all W11 production releases prior to 22623...worked perfectly!
mikeyww wrote:software designers will add command lines or hotkeys to toggle their windows, or that running the program will activate its window
I use it to provide a robust menu structure for my programs without needing a desktop presence, i.e., all the menus are triggered from icons in the system tray. For example, I wrote a program that lets you toggle CapsLock, NumLock, and ScrollLock via three icons in the tray:

CapsLock NumLock ScrollLock.jpg
CapsLock NumLock ScrollLock.jpg (1.33 KiB) Viewed 881 times

A red icon means the key is off; green means it is on. The program contains no visible windows...all operations are controlled by menus/submenus via the system tray icons, e.g.:

CapsLock system tray menu.jpg
CapsLock system tray menu.jpg (18.88 KiB) Viewed 881 times

Note the Move all key icons to Beginning of tray and Move all key icons to End of tray menu picks. I use the TrayIcon library to do that. Regards, Joe
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 14:08

Hmm. I've had varying luck in terms of activating (unhiding) windows of tray-resident programs; I think it depends on the specific programs and how they are written. As you know, you can write an AutoHotkey script that does various things, including nothing, when clicking, double-clicking, or right-clicking on its icon.
User avatar
JoeWinograd
Posts: 2214
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 14:23

Interesting! I've never had problems with a menu pick in a tray icon...it always works, although I wouldn't describe it as "unhiding" a window...it simply executes the goto-label, which sometimes displays a MsgBox, sometimes a GUI, sometimes no display...just runs some code. Of course, none of that has anything to do with the TrayIcon library.
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 14:58

I am referring to other tray-resident programs (not AutoHotkey)-- trying to get the tray icon library to work with them. It often works, but not always.
User avatar
JoeWinograd
Posts: 2214
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 15:09

Ah, OK, I missed that...I use the TrayIcon lib only for AHK-based programs.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 15:12

Ralf_Reddings200244, use iaccessible or uiautomation for such a task.
User avatar
JoeWinograd
Posts: 2214
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

26 Jun 2023, 16:18

malcev wrote:use iaccessible or uiautomation for such a task
Please provide a link...thanks!
User avatar
JoeWinograd
Posts: 2214
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

28 Jun 2023, 14:10

Hi @malcev,
Thanks for the link. To be clear, are you saying that the code in that thread can be used as the basis for getting information about the system tray icons and moving them to different positions in the tray (just as the TrayIcon library can)? Regards, Joe
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

28 Jun 2023, 15:01

No. I just answered on topic starter question - send click to tray icon.
User avatar
JoeWinograd
Posts: 2214
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: WIN 10/11: Can anyone else confirm if this library works on windows 11?

28 Jun 2023, 16:50

OK, thanks for clarifying.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: apeironn and 251 guests