Jump to content
Sign in to follow this  

Multiple Autoit icons on WinXP Tray

Recommended Posts

Every time I run my AutoIt script from the script editor, I get a new AutoIt icon in the Traybar. They build up so that there can be 10 or more. If I mouse over them, they quickly disappear. Could this be a bug?

Share this post

Link to post
Share on other sites

I'm assuming you are using XP. I think it's the OS that keeps the icon there when you kill the program. If you exit correctly instead of 'Stopping' the script with the editor, then the Icon disappears. Just add an exit or close function in the scripts from now on.

Also, I came across a 'RefreshSystemTray' UDF not too long ago. It's not mine, but it works:

; ===================================================================
; _RefreshSystemTray($nDealy = 1000)
; Removes any dead icons from the notification area.
; Parameters:
;   $nDelay - IN/OPTIONAL - The delay to wait for the notification area to expand with Windows XP's
;       "Hide Inactive Icons" feature (In milliseconds).
; Returns:
;   Sets @error on failure:
;       1 - Tray couldn't be found.
;       2 - DllCall error.
; ===================================================================
Func _RefreshSystemTray($nDelay = 1000)
; Save Opt settings
    Local $oldMatchMode = Opt("WinTitleMatchMode", 4)
    Local $oldChildMode = Opt("WinSearchChildren", 1)
    Local $error = 0
    Do; Pseudo loop
        Local $hWnd = WinGetHandle("classname=TrayNotifyWnd")
        If @error Then
            $error = 1

        Local $hControl = ControlGetHandle($hWnd, "", "Button1")

    ; We're on XP and the Hide Inactive Icons button is there, so expand it
        If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then
            ControlClick($hWnd, "", $hControl)

        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; Jump out of While/While/Do
                $x = $x + 8
            $y = $y + 8
        DllCall("user32.dll", "int", "SetCursorPos", "int", $posStart[0], "int", $posStart[1])
    ; We're on XP so we need to hide the inactive icons again.
        If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then
            ControlClick($hWnd, "", $hControl)
    Until 1

; Restore Opt settings
    Opt("WinTitleMatchMode", $oldMatchMode)
    Opt("WinSearchChildren", $oldChildMode)
EndFunc; _RefreshSystemTray()

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...