Dargonis Posted February 16, 2011 Share 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") Link to comment Share on other sites More sharing options...
Xenobiologist Posted February 16, 2011 Share 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 maniootek and toasterking 2 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 Link to comment Share on other sites More sharing options...
Dargonis Posted February 16, 2011 Author Share 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* Link to comment Share on other sites More sharing options...
priyo Posted May 3, 2012 Share Posted May 3, 2012 May I know why dead process icons stays in tray notification area? Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 3, 2012 Share 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 Link to comment Share on other sites More sharing options...
Marcelos Posted September 30, 2013 Share Posted September 30, 2013 Thanks much, works perfectly Graphical Control - Week Planner Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now