Nety Posted August 14, 2011 Share Posted August 14, 2011 I have the following which is part of a larger script which checks for running processes and displays them so the user can close them before continuing. However I cannot seem to get it to not loop one more time once all programs are closed. It shows a empty list. How can I get it not loop that last time? $Title = "Start" While $Title <> "" Local $List = WinList() Local $Title = "" For $i = 1 To $List[0][0] If $List[$i][0] <> "" And IsVisible($List[$i][1]) and $List[$i][0] <> "Start" and $List[$i][0] <> "Program Manager" Then Dim $Process = IDtoName( WinGetText($List[$i][0])) ;$Title &= $Process & @TAB & $List[$i][0] & @CRLF $Title &= @TAB & $List[$i][0] & @CRLF EndIf Next msgbox(0,"SAP 7.2 Upgrade", "The following programs are running. They must be closed before the upgrade can continue..." & @CRLF & @CRLF & $Title & @CRLF & @CRLF & "Please close them and then click OK to continue") WEnd Func IDtoName($Handle) Dim $ProcList = ProcessList() For $i = 1 To $ProcList[0][0] If $ProcList[$i][1] = $Handle Then Return ($ProcList[$i][0]) EndIf Next EndFunc Func IsVisible($Handle) If BitAND( WinGetState($Handle), 2) Then Return 1 Else Return 0 EndIf EndFunc Link to comment Share on other sites More sharing options...
MvGulik Posted August 14, 2011 Share Posted August 14, 2011 (edited) Wrong assumption interpretation. Your running the right number of loops.But you do not test ($Title) for the end result (=='') when displaying your message box.Ergo: Empty list on last msg-prompt. Edited August 14, 2011 by iEvKI3gv9Wrkd41u "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
Nety Posted August 15, 2011 Author Share Posted August 15, 2011 OK so I have added the a If $Title == "" check in as below. Is this the best way to check? It works While $Title <> "" Local $List = WinList() Local $Title = "" For $i = 1 To $List[0][0] If $List[$i][0] <> "" And IsVisible($List[$i][1]) and $List[$i][0] <> "Start" and $List[$i][0] <> "Program Manager" Then Dim $Process = IDtoName( WinGetText($List[$i][0])) ;$Title &= $Process & @TAB & $List[$i][0] & @CRLF $Title &= @TAB & $List[$i][0] & @CRLF EndIf Next If $Title == "" Then ExitLoop Else msgbox(0,"SAP 7.2 Upgrade", "The following programs are running. They must be closed before the upgrade can continue..." & @CRLF & @CRLF & $Title & @CRLF & @CRLF & "Please close them and then click OK to continue") EndIf WEnd Link to comment Share on other sites More sharing options...
MvGulik Posted August 15, 2011 Share Posted August 15, 2011 Nothing wrong with how you did it. Possible (example) alternative would be:If Not ($Title == "") Then msgbox(0,"SAP 7.2 Upgrade", "The following programs are running. They must be closed before the upgrade can continue..." & @CRLF & @CRLF & $Title & @CRLF & @CRLF & "Please close them and then click OK to continue") EndifIf $Title Then msgbox(0,"SAP 7.2 Upgrade", "The following programs are running. They must be closed before the upgrade can continue..." & @CRLF & @CRLF & $Title & @CRLF & @CRLF & "Please close them and then click OK to continue")If Not $Title Then ExitLoop msgbox(0,"SAP 7.2 Upgrade", "The following programs are running. They must be closed before the upgrade can continue..." & @CRLF & @CRLF & $Title & @CRLF & @CRLF & "Please close them and then click OK to continue") Its somewhat a matter of taste. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
Nety Posted August 15, 2011 Author Share Posted August 15, 2011 Awesome thanks for your help. 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