Sign in to follow this  
Followers 0
Hooch

Refresh systray?

21 posts in this topic

Anyone aware of a way to "refresh" the systray? I keep getting ghost icons down there.

Share this post


Link to post
Share on other sites



Moving the mouse over them is the only method currently. There is no internal function or any other trick, except moving the mouse.

Share this post


Link to post
Share on other sites

Also "Closing" application in the gentle way should not keep any icon... If you can avoid killing them.

Share this post


Link to post
Share on other sites

Ah ok, figured as much but I was hopefull. I am terminating the process so it's not surprising. Maybe I'll see if there is a gentler way to stop an autoit gui, killing the process was the first method I saw. If only we could run two gui's... :ph34r:

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I am looking for a refresh systray option myself and as this thread is very old, perhaps something has come along since then.

The URLs below give 2 for refreshing the systray so that closed apps stop have their icons showing up in it. However, I tested them both and they don't work. I still have to physically move the mouse over the systray to get rid of icons. I have the show icons _on_ in XP, however, so wondering if that might be screwing things up (?). In other words, I have no icons hidden as XP is such a treat and kept forgetting what it was supposed to hide so every couple of weeks would have to remind it what to show and what to hide. So after getting fed up, now just showing them all permanently.

http://www.autoitscript.com/forum/index.ph...&hl=systray

http://www.autoitscript.com/forum/index.ph...404&hl=tray

[My AI version: v3.2.5.0 (beta).]

Thanks. :P

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I posted this a while back:

Here: http://www.autoitscript.com/forum/index.ph...;hl=refreshtray

And here: http://www.autoitscript.com/forum/index.ph...;hl=refreshtray

RefreshTray()
Func RefreshTray()
    $speed = 5
    $original = MouseGetPos()
    MouseMove (10,10)
    MouseMove (10,@DesktopHeight - 10, $speed)
    MouseMove (@DesktopWidth - 10,@DesktopHeight - 10, $speed)
    MouseMove (@DesktopWidth - 10,10, $speed)
    MouseMove (10,10, $speed)
    MouseMove ($original[0],$original[1])
EndFunc
Edited by weaponx

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Oh, well, pooh! This one doesn't work either. Wonder what's up with this computer. I have the first part of the AI script close potentially running programs. I tested it again by starting up 2 apps then closing them with the ProcessClose if process is running. That part works fine but the icons stay in the systray until one physically and manually moves the mouse over the systray. Earlier today, I didn't realize I hadn't cleared an icon and kept hitting a button trying to get the program to work only to then realize that it wasn't actually running. Bother. Any suggestions?

Thank you so very much for this. If it had worked for me, it would be super great! Wonder what this could mean. Comments in the other thread said that it worked for other people. <sigh> :P

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I posted this a while back:

Here: http://www.autoitscript.com/forum/index.ph...;hl=refreshtray

And here: http://www.autoitscript.com/forum/index.ph...;hl=refreshtray

RefreshTray()
Func RefreshTray()
    $speed = 5
    $original = MouseGetPos()
    MouseMove (10,10)
    MouseMove (10,@DesktopHeight - 10, $speed)
    MouseMove (@DesktopWidth - 10,@DesktopHeight - 10, $speed)
    MouseMove (@DesktopWidth - 10,10, $speed)
    MouseMove (10,10, $speed)
    MouseMove ($original[0],$original[1])
EndFunc
This method is flawed. Sure, you think you're being clever by running a full box around the screen covering the situation where the taskbar is at any side of the screen. But you forgot: The taskbar can be more than one row thick. If I increased the height of my taskbar and had a dead icon in the top row, your code would not work.

Oh, well, pooh! This one doesn't work either. Wonder what's up with this computer. I have the first part of the AI script close potentially running programs. I tested it again by starting up 2 apps then closing them with the ProcessClose if process is running. That part works fine but the icons stay in the systray until one physically and manually moves the mouse over the systray. Earlier today, I didn't realize I hadn't cleared an icon and kept hitting a button trying to get the program to work only to then realize that it wasn't actually running. Bother. Any suggestions?

Thank you so very much for this. If it had worked for me, it would be super great! Wonder what this could mean. Comments in the other thread said that it worked for other people. <sigh> :P

Write a simple AutoIt script to move the mouse very slowly across the notification area. Does that work? It could be that things are going too fast or too slow for Windows to realize the mouse passed over the area.

Edit: Note, I'm not offering that as a solution, merely a test to see if AutoIt can clear the dead icons if the mouse is automated slowly enough.

Edited by Valik

Share this post


Link to post
Share on other sites

This method is flawed. Sure, you think you're being clever by running a full box around the screen covering the situation where the taskbar is at any side of the screen. But you forgot: The taskbar can be more than one row thick. If I increased the height of my taskbar and had a dead icon in the top row, your code would not work.

Ouch.

I was definitely aware of this. I wasn't prescribing a cure for the common cold, just some Vitamin C if you get my drift. When someone comes up with a good dllcall that fixes this I will refer that instead of my crap code.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Ouch.

I was definitely aware of this. I wasn't prescribing a cure for the common cold, just some Vitamin C if you get my drift. When someone comes up with a good dllcall that fixes this I will refer that instead of my crap code.

I didn't quite understand all of what was said in the previous post. I'm guessing that there is no real way to get the cursor to move, I take it? If that's the case, well, what can one do. I'll just have to try to remember to move the mouse over the systray whenever I use my close script.

Thanks. :P

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites

This script I posted works, just not on everybodys system. It doesn't take double stacked taskbars into account, but it should be able to work regardless of where your taskbar is located.

Share this post


Link to post
Share on other sites

Ouch.

I was definitely aware of this. I wasn't prescribing a cure for the common cold, just some Vitamin C if you get my drift. When someone comes up with a good dllcall that fixes this I will refer that instead of my crap code.

I defer you to my function and my post, then. There is no way to refresh the notification area except for mousing over it. So your "vitamin C" is just getting in the way of my "cure all". Another rather significant flaw with yours is it doesn't even concern itself with hidden icons (If you would notice, that was the very first reply to my function). As far as I know, the only issue with my function is it won't remove multiple dead and hidden icons (the icons collapse and are not re-expanded).

Diana, I don't know what the issue is on your system. The code works fine for me and always has. Other than speed, I don't know what issue could be at work here, unless the function is just not finding the notification area, for some strange reason.

Share this post


Link to post
Share on other sites

@Valik - I already owned up to the fact that what I submitted wasn't an all-encompassing solution (written in 2 minutes). Diana posted two links that didn't work as expected so I was just making a brainstorming contribution.

I feel like you are really calling me out on this. Admittedly I didn't see your script before I posted, but I never once said that this is the only option.

Share this post


Link to post
Share on other sites

@Valik - I already owned up to the fact that what I submitted wasn't an all-encompassing solution (written in 2 minutes). Diana posted two links that didn't work as expected so I was just making a brainstorming contribution.

I feel like you are really calling me out on this. Admittedly I didn't see your script before I posted, but I never once said that this is the only option.

I'm not quite sure why you're taking this attitude. You stated (and I shall quote):

When someone comes up with a good dllcall that fixes this I will refer that instead of my crap code.

And I have done just that. I've provided a better function (the fact that it uses DllCall() is ancillary). I think it's important for it to be pointed out why your code is crap, particularly since there is superior code available.

Share this post


Link to post
Share on other sites

Very nice Valik, I didn't know that was out there, thank you!

@weaponx, I don't understand why the attack from Valik, but I always appreciate good brainstorming, and I know you have helped me in a tight spot on multiple occasions, so thank you also.

@Valik, come on man, no need to attack the code like that... it was a great workaround that worked for over 95% of people ( I would assume )... YES, yours is better, but just like you, weaponx is here a lot, trying to help poor saps like me.

Anyways, just hate to see intelligent people get at each others throats.

Share this post


Link to post
Share on other sites

@Valik, come on man, no need to attack the code like that... it was a great workaround that worked for over 95% of people ( I would assume )...

Workaround for what?

Share this post


Link to post
Share on other sites

For refreshing the sys tray, before he knew about your code... what did you think I was referring to?

Share this post


Link to post
Share on other sites

Oh, well, pooh! This one doesn't work either. Wonder what's up with this computer. I have the first part of the AI script close potentially running programs. I tested it again by starting up 2 apps then closing them with the ProcessClose if process is running. That part works fine but the icons stay in the systray until one physically and manually moves the mouse over the systray. Earlier today, I didn't realize I hadn't cleared an icon and kept hitting a button trying to get the program to work only to then realize that it wasn't actually running. Bother. Any suggestions?

Thank you so very much for this. If it had worked for me, it would be super great! Wonder what this could mean. Comments in the other thread said that it worked for other people. <sigh> :P

The following is a "non-MouseMove" method. Using tuape's "SysTray UDF" I was able to remove "ghost" System Tray icons with the script below.

Note: I had to comment out the UDF's $WM_GETTEXT = 13 line because of a "previously declared contant" error.

Basically it amounts to enumerating the icons and the handles of their processes, compared to a list of those from active windows, and then removes the icon if a corresponding process no longer exists.

#include "SysTray.au3"
#NoTrayIcon

$titles = _SysTrayIconTitles()

For $i = 0 To (UBound($titles) -1)
    If $titles[$i] = "" Then
        _SysTrayIconRemove($i)
    EndIf
Next

Hope it helps,

- Mo


- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Pretty good idea Monamo. I'm surprised some if this stuff isn't in Tray Functions in the help file.

Share this post


Link to post
Share on other sites

Pretty good idea Monamo. I'm surprised some if this stuff isn't in Tray Functions in the help file.

Thanks, it was the result of about 5+ hours trolling through .DLL's with Dependency Walker, Google, and finally this page, which led me to look into user32.dll's SendMessage function trying to expand upon the TB_BUTTONCOUNT parameter. That one led me back to the forums and I found that Systray UDF.

I was going to try to put together a self-contained package, but since the whole DllStructCreate() bit scares me and small children still, I decided to stick with a UDF that seemed well put together.


- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0