Sign in to follow this  
Followers 0
MarioX

How to avoid "doubled" system tray icons

10 posts in this topic

#1 ·  Posted (edited)

I see often that the attempt to ProcessClose a process with a tray icon kill the task but leave the icon visible, you need to over the icon with mouse cursor to allow disappear it.

There is a way to "refresh" the system tray icons after killing a process ?

Edited by MarioX

Share this post


Link to post
Share on other sites



as far as i know, moving your mouse over the icon in the tray is the only way.... but i'm not really skilled at this stuff so you should probably take a second opinion

Share this post


Link to post
Share on other sites

Have you tried doing a MouseMove() over the system tray to refresh it?

:P

Share this post


Link to post
Share on other sites

Have you tried doing a MouseMove() over the system tray to refresh it?

:P

Thanks all for the help. The trids idea sound interesting, but since I'm a really beginner user I'm interested in getting some help about the needed code...

It's probably necessary to know the lenght of the tray icons area and it's height.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks all for the help. The trids idea sound interesting, but since I'm a really beginner user I'm interested in getting some help about the needed code...

It's probably necessary to know the lenght of the tray icons area and it's height.

There is a UDF called Systray_UDF by Taupe that can be used to find the position of the system tray icon. You can then use mousemove to move the mouse to the correct place. Do a search in Scripts and Scraps for Systray_UDF and you will find it.

Edit

Here it is

Edited by BigDod


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Hi Mario,

The code in the link that I posted wouldn't work for me on a W2K system. It ran, but it didn't refresh the system tray icons.

So I had a look at the other code in the other link that you posted: http://www.autoitscript.com/forum/index.php?showtopic=18052

That code wasn't working for me either, but I found this snippet much easier to understand. What was happening was that the mouse was moving along the bottom of the SystemTray rather than across the middle (and over the icons). So I made a few modifications to that script which has worked for me, and might perhaps work for you.

Func RefreshSystemTray()
    
    Local $CurrentPos = MouseGetPos()
    AutoItSetOption("WinTitleMatchMode", 4)
    Local $Tray = WinGetClientSize("classname=Shell_TrayWnd", "")
    
    if not @error then
    Local $MiddleofSysTray = @DesktopHeight - int($Tray[1]/2)
        for $i = 5 to $Tray[0] - 5 Step 5
            MouseMove($i, $MiddleofSysTray, 1)
        Next
    MouseMove($CurrentPos[0], $CurrentPos[1], 1)
    EndIf

EndFunc

I should note that my logic is based on MikeOsdx's original script, without which I would not have been able to figure this out. The above code doesn't need the beta to run.

One other point, moving the mouse pointer across the middle of the System Tray (actually the whole bottom of the desktop) is noticeable when it happens. This isn't a problem for me, as the script I am using this code in runs late at night when nobody is watching the desktop - and I just want to refresh the system tray icons.

I suspect that MikeOsdx pushed the mouse pointer lower to make it more discreet, trouble is that I think he went a little to close to the bottom of the screen.

Anyway if you want the movement of the mouse across the SystemTray to be as discreet as possible, you may have to experiment with different values for $MiddleofSysTray (i.e. effectively change the Y-axis mouse position value to $BottomofSysTray).

Hope it helps.

Cheers,

VW

Share this post


Link to post
Share on other sites

If you want it as discreet as possible, you need to be using my function. MouseMove() is extremely slow (Comparatively speaking). My function covers every pixel in the tray in a fraction of the time it takes MouseMove() to do one row.

Share this post


Link to post
Share on other sites

I've tested the Valik function and it work absolutely fine. It's also "smart" because did not interfere with Gui's desktop mouse etc.

I will later test the VeeDub tweaked function.

I also confirm that the original function fail to clean dead icons on my system.

A BIG thanks to all of you for the support!

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