The one question I have to ask is: What are you doing that leaves so many orphaned icons so often?
Also, I'd be interested to know if the attached version of CleanTray works, I've modified it so that it works one of two ways which I'll refer to as Nuke'em
Where: [anything] = anything, any argument at all.A number from 1 to 100 = Boring
slow way = moving mouse over all the icons, the lower the number the faster it moves, I suggest you start with 5.No args, a string or 0 = Nuke'em
= Much faster with an absolute total disregard of resulting icon order, (the way I like since I have to restart explorer.exe to get all the icons to show up in the first place).
So in your case, try:
C:\> CleanTray.exe 2
I realise that AutoIt and AHK are two different languages but it seems that we have one script that removes ALL orphaned icons but plays havoc with icon location and a second script that only affects orphaned icons but will not remove more than 2 at a time. Putting aside the different languages they are written in what are they actually doing differently?
AutoIt script, (original CleanTray), gets the number of icons in the tray then asks for the process that controls that icon. If no process is returned the icon is removed - obviously in using the appropriate system calls to remove the icon, it also removes the positioning info.
The first AutoHK script moves the mouse over the icons but you need to specify a coordinate offset based on your screen parameters. The second AutoHK script works the same as CleanTray by using system calls to detect icons without processes and then removing them.
The new CleanTray works depending on the passed argument:a)
The original way, ie. just removes the icon if it has no background process.b)
Locates the tray, gets the number of icons, it then loops backwards through the list getting the icon' background process. If an icon has no background process, the mouse is moved to it, Windows will then remove it, (as it usually does). If an icon is removed it will exit the loop, get the new number of icons and start again, ie. it will recurse, (kind of), through the icon list until it gets to the point where no icons are removed.
REDUNDANT: See below