Dargonis 0 Posted February 16, 2011 I'm working on a project to upgrade an existing search tool which is in everyones PC tray. In order to upgrade it I have to kill the search tool process, run the upgrade, and then relaunch the tool. The script does all that I need except that a workstation then shows it has TWO of the same ICON in the tray until they physically move their mouse over Icon that was supposed to be closed in the tray.. only then will it disappear. I've read that a tray refresh function of some type has been posted but can't find it anywhere. Could someone point me to it, or tell me how I can make the icon go away after a process close? Here's what I have... #include <Process.au3> ;FILEINSTALL OF THE MSI SOURCE FileInstall ( "C:\TEMP\employee_search4.msi", "C:\TEMP\employee_search4.msi" ) ;STOP EXECUTION OF THE EMPLOYEE SEARCH TOOL ProcessClose ( "Employee Search.exe") ;EXECUTION OF THE INSTALL SOURCE MSI RunWait ("msiexec.exe", '/i C:\TEMP\employee_search.msi /qn') ;RELAUNCH OF THE EMPLOYEE SEARCH TOOL AFTER INSTALL IF @OSArch = "X64" Then Run ( "C:\Program Files (x86)\IBM\LBPS\Employee Search\Employee Search.exe") Else Run ( "C:\Program Files\IBM\LBPS\Employee Search\Employee Search.exe") EndIf ;CLEANUP FileDelete ( "C:\TEMP\eployee_search4.msi") Share this post Link to post Share on other sites
Xenobiologist 47 Posted February 16, 2011 Hi, try this: expandcollapse popup; =================================================================== ; _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 ExitLoop EndIf 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) 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; Jump out of While/While/Do EndIf $x = $x + 8 WEnd $y = $y + 8 WEnd 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) EndIf Until 1 ; Restore Opt settings Opt("WinTitleMatchMode", $oldMatchMode) Opt("WinSearchChildren", $oldChildMode) SetError($error) EndFunc; _RefreshSystemTray() Mega 2 maniootek and toasterking reacted to this 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
Dargonis 0 Posted February 16, 2011 Thanks Xeno! That worked perfectly. Ran it on WIN7 x86, x64 and XP x86 good to go in all cases. *salute* Share this post Link to post Share on other sites
priyo 0 Posted May 3, 2012 May I know why dead process icons stays in tray notification area? Share this post Link to post Share on other sites
Xenobiologist 47 Posted May 3, 2012 I guess it is because the window isn't redrawn. Move the mouse over the icon and then it should disappear. 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
Marcelos 1 Posted September 30, 2013 Thanks much, works perfectly Graphical Control - Week Planner Share this post Link to post Share on other sites