Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Set a random tray icon for your script


  • Please log in to reply
No replies to this topic
adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006
I know sometimes I have many AHK scripts running at the same time. It's confusing to tell the difference between all the square green icons with a white H in them without hovering the mouse over them.

I wrote a simple function to set the tray icon as a randomly selected icon from shell32.dll.

This helps me keep track of newly launched scripts, since it will most likely always be an icon that sticks out when you glance at the system tray.

You may need to tweak the max random value for different versions of windows. Right now it is set to work for Windows 7. If it picks an icon number that is not in shell32 it will return a "1".

SetRandomTrayIcon()	{
	Random,r,1,306
	Menu,Tray,UseErrorLevel,on
	Menu,Tray,Icon,Shell32.dll,%r%
	Return ErrorLevel
}