Windows 11 compatibility problem with this script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Cariboudjan
Posts: 9
Joined: 14 Jul 2020, 21:12

Windows 11 compatibility problem with this script

Post by Cariboudjan » 20 Sep 2021, 08:56

I'm using this script with arguments to indicate where to open the Shell_TrayWnd icon overflow window from the system tray. The ahk_class name has changed in Windows 11. Does anyone know what this new class name is so that I can adapt this script for the new operating system?

Example in command prompt for position 100 X and 100 Y:

Code: Select all

ActivateTray.ahk "100" "100" "0"

Code: Select all

#SingleInstance, force
#NoTrayIcon
DetectHiddenWindows, On
SetWinDelay, 16
X = %1%
Y = %2%
direction = %3%
IfWinActive, ahk_class NotifyIconOverflowWindow
WinHide, ahk_class NotifyIconOverflowWindow
Else {
WinGetPos,,,WidthOfTray,HeightOfTray,ahk_class NotifyIconOverflowWindow
TrueX := X-WidthOfTray/2
TrueY := Y-1.5
WinSet, Transparent, 0, ahk_class NotifyIconOverflowWindow
ControlClick, Button2, ahk_class Shell_TrayWnd
WinMove, ahk_class NotifyIconOverflowWindow, , %TrueX%, %TrueY%
WinSet, Transparent, OFF, ahk_class NotifyIconOverflowWindow
loop {
WinMove, ahk_class NotifyIconOverflowWindow, , %TrueX%, %TrueY%
IfWinNotActive, ahk_class NotifyIconOverflowWindow
ExitApp
}
}

User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: Windows 11 compatibility problem with this script

Post by mikeyww » 20 Sep 2021, 09:01

If you don't know the class name, then how do you know that it has changed?

I do not have Win11, but if you run Window Spy, it can show you the complete WinTitle. At that point, I would backtrack, to see whether you can issue one or two commands successfully using that class.

Cariboudjan
Posts: 9
Joined: 14 Jul 2020, 21:12

Re: Windows 11 compatibility problem with this script

Post by Cariboudjan » 20 Sep 2021, 12:43

I don't have Windows 11 installed on my PC right now. Would anyone else be able to tell me the window name from WindowSpy when opening the icon overflow in the system tray?

EDIT:

Figured it out. Changed Button2 to Button1... :angel: Didn't think the solution would be that simple.

Side question
How do I figure out what ButtonX numbers do what on the taskbar, or is it just trial and error?

lexikos
Posts: 9560
Joined: 30 Sep 2013, 04:07
Contact:

Re: Windows 11 compatibility problem with this script

Post by lexikos » 25 Sep 2021, 05:21

Side answer: look at the button's text, position, size and/or parent window.

On my Windows 10 taskbar, Button1 has the text "Type here to search", so its purpose should be fairly obvious. The button itself is hidden and does not function, unless the taskbar search option is set to "Show search box". Button2 has no text, but its parent window is the TrayNotifyWnd1 control; it's obviously the button that shows the icon overflow.

The numbers are assigned by z-index (usually the order the controls were created in, which sometimes coincides with their position).

WinGet ControlList can be used to retrieve them all, so you can click the last Button.

Cariboudjan
Posts: 9
Joined: 14 Jul 2020, 21:12

Re: Windows 11 compatibility problem with this script

Post by Cariboudjan » 27 Sep 2021, 12:03

Thanks! Changed it from Button2 to Button1 fixed the issue.

Post Reply

Return to “Ask for Help (v1)”