Control the order (change the position) of system tray icons

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Control the order (change the position) of system tray icons

12 Nov 2018, 22:00

Hi Folks,
I'm working on a script that allows multiple instances (#SingleInstance off) and provides an option for a different color icon in the system tray for each instance (Menu,Tray,Icon,%ColorIcon%). The user has a choice of a dozen colors.

Environment is AHK v1.1.30.01 U32. The script will be compiled and used in an installer (Setup.exe) that must run on 32-bit and 64-bit W7, W8/8.1, and W10 (XP and Vista would be nice, but are not necessary).

The color (blue, green, red, yellow, etc.) is the first (and only) parameter to the script. The tray context menu is configurable by the user, but one of the menu choices is always Refresh context menu. When the user clicks that, my script does this:

Code: Select all

Run,%A_ScriptFullPath% /restart %Color%
Here's the problem: Users tell me that they want the colors to appear in the same order (position) in the system tray. For example, if they're using cyan, gold, and pink, they want the icons always to be in that order. But when they do a Refresh context menu on one of the colors, the order of the icons changes.

Here's the question: Is there a way for my script to control the order (change the position) of its numerous color icons in the system tray?

Thanks much, Joe
iPhilip
Posts: 814
Joined: 02 Oct 2013, 12:21

Re: Control the order (change the position) of system tray icons

13 Nov 2018, 14:44

Did you try Fanatic Guru's TrayIcon_Move function? Here's the link.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Control the order (change the position) of system tray icons

13 Nov 2018, 15:30

Hi iPhilip,
Thanks for the comment. Yes, I had already tried it before posting this question. I could not get it to work...nothing moved when I called it. TrayIcon_GetInfo worked fine, but TrayIcon_Move did not, and neither did TrayIcon_Delete. Regards, Joe
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Control the order (change the position) of system tray icons

13 Nov 2018, 16:19

Hi iPhilip,
Your post inspired me to look again at my test code that calls FG's TrayIcon_Move...turns out I was calling it wrong! My mistake...it's working fine! Regards, Joe
iPhilip
Posts: 814
Joined: 02 Oct 2013, 12:21

Re: Control the order (change the position) of system tray icons

13 Nov 2018, 16:41

Great! :)
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: gongnl, Google [Bot], Rohwedder and 267 guests