Sign in to follow this  
Followers 0
Mixam

How to refresh the tray

4 posts in this topic

So far the only solution I have is to mouse over them. I've been told theres a function in user32.dll that you can call to refresh or recall the taskbar (the entire thing)

Could anyone help me?

The icons are all there from me killing a program improperly when it freezes. I know I could use close instead of kill when the program is not frozen, but it usually is frozen hence why I use kill

I'm pretty new to Auto It, been coding for about 2-3 weeks now. So please bear that in mind.

Thanks in advance for all your help.

Share this post


Link to post
Share on other sites



Hi,

this might not be the best solution, but I guess it works.

_RefreshSystemTray()

Func _RefreshSystemTray($nDelay = 1000)
    Local $oldMatchMode = Opt("WinTitleMatchMode", 4)
    Local $oldChildMode = Opt("WinSearchChildren", 1)
    Local $error = 0
    Do
        Local $hWnd = WinGetHandle("classname=TrayNotifyWnd")
        If @error Then
            $error = 1
            ExitLoop
        EndIf
        Local $hControl = ControlGetHandle($hWnd, "", "Button1")
        
        If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then
            ControlClick($hWnd, "", $hControl)
            Sleep($nDelay)
        EndIf
        Local $posStart = MouseGetPos()
        Local $posWin = WinGetPos($hWnd)    
        Local $y = $posWin[1]
        While $y < $posWin[3] + $posWin[1]
            Local $x = $posWin[0]
            While $x < $posWin[2] + $posWin[0]
                DllCall("user32.dll", "int", "SetCursorPos", "int", $x, "int", $y)
                If @error Then
                    $error = 2
                    ExitLoop 3;
                EndIf
                $x += 8
            WEnd
            $y += 8
        WEnd
        DllCall("user32.dll", "int", "SetCursorPos", "int", $posStart[0], "int", $posStart[1])
        If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then
            ControlClick($hWnd, "", $hControl)
        EndIf
    Until 1
    Opt("WinTitleMatchMode", $oldMatchMode)
    Opt("WinSearchChildren", $oldChildMode)
    SetError($error)
EndFunc

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Wow that a bit complicated for me right now. Maybe after I get some sleep and go over it piece by piece. Is there any solution that will work while the computer is locked by chance? I guess I also should have specified I'm in win xp in case it makes a difference. Anyways I'm off to bed I will check back for more posts in the morning, and take a closer look at that script. Thanks

Edit: Oh and i just reread that other post. I don't think clicking on all the tray icons will be such a good idea as clicking on my auto it script pauses it...

Edited by Mixam

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