ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Advice needed on AHK script

<< < (2/8) > >>

pilgrim:
Thanks for the links but no joy.

To start with, since I added the fourth program to my batch file the original script now removes 2 icons at a time.

Regarding the links:
The exe does not work, one of the posters in the link had the same trouble.
The script at the bottom of the page did not work either.
The script at the top of the page removed 2 icons the same as my original script now does but it is 8 times the size.

I have just spent the last hour trying different variations on the original script.
I tried altering the x numbers, nothing.
I tried pushing the loop as high as x20, nothing.

So I am back to the idea of running the script more than once.

4wd:
And yet another option :)

Here's a simple AutoIt script that will bounce the mouse over tray icons that have a running process, it may pick up orphaned icons as it jumps from one to another.

It's just a modified version of the SysTray_Example.au3 found here along with the UDF by tuape.

Attached code redundant - see below.

pilgrim:
I think I'll cry.

4wd,

ClearTray.exe did absolutely nothing. While CleanTray.exe which you uploaded on another thread of mine a week ago works perfectly except for one thing, however many icons it deletes it leaves that number of empty spaces on the right hand end of the tray and rearranges any icons it closes the next time they start as well as the icons of any programs that happen to be open at the time.

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?


Sometime later:

This has got to be the worst idea for an AHK script that anybody ever came up with but it works:

I went back to the original script and copied it, then I pasted it below the original, I did the same thing until I had 4 copies one below the other and then saved it.
Guess what? It worked.


Sometime later still:

I think I've found the answer to empty spaces at the right hand end of the tray.
I have compiled the script and added it to my batch file where it works perfectly but if I have the Task Manager open when I run it then I get empty spaces in the tray, if I shut the Task Manager down everything in the tray moves to the right and the spaces disappear.
If the Task Manager is not open when I run the batch file, no spaces?

4wd:
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 and Boring :)

CleanTray.exe [anything]

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?
--- End quote ---

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

pilgrim:
The one question I have to ask is: What are you doing that leaves so many orphaned icons so often?
--- End quote ---

The answer to that is in the thread I linked to in reply 2 of this thread.
I have since added Network Activity Indicator to the list as I only need it running when connected, so every time I go offline I have 4 orphan icons.

Also, I'd be interested to know if the attached version of CleanTray works.
--- End quote ---

I'm on my Netbook at the moment, I'll try it out when I get back on my main PC.

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.
--- End quote ---

I had a feeling that the difference was something along those lines but I didn't understand the scripts well enough to be sure. Thanks for telling me.

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.
--- End quote ---

That sounds involved. I was interested in your comment about the speed of the program.
When I ran the program I made yesterday on Windows 7 it was pretty quick, once the connection had shut down the NAI icon just had enough time to go grey (indicating no connection) before all 4 icons disappeared virtually together.
I added it to my Netbook earlier (XP) and it takes 2 or 3 seconds for everything to shut down and disappear with only 3 icons, there is of course a tremendous resource difference.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version