nikink Posted September 12, 2006 Posted September 12, 2006 (edited) Hi, Is there any way to wait for an unknown window? I'm still trying to automate a Nero Cleantool program, and when the cleantool.exe is run it spends a few seconds checking the computer for installed Nero applications then comes up with one of two windows depending on whether it found any installed Nero components or not. My current method of solving this is messy: $NeroIsDetected = 1 ; Assume Nero is present on the PC by default Sleep(5000) ; Give the cleantool a few seconds to discover stuff While 1 If WinExists("Browse for Folder") Then ;Nero does not exist $NeroIsDetected = 0 NeroIsNotOnThisComputer() Exitloop Else If WinExists("Nero General CleanTool") And $NeroIsDetected Then ;Nero Exists UninstallNeroStepByStep() ExitLoop Else Sleep(100) ; wait a bit longer for a window to appear EndIf EndIf WEnd Is there a better way? I'm unhappy with it especially cuz this script needs to run on several models of PC and so the Sleep(5000) maybe too short or too long and I'd like to get rid of it if possible. Edited September 12, 2006 by nikink
jpm Posted September 12, 2006 Posted September 12, 2006 Hi, Is there any way to wait for an unknown window? I'm still trying to automate a Nero Cleantool program, and when the cleantool.exe is run it spends a few seconds checking the computer for installed Nero applications then comes up with one of two windows depending on whether it found any installed Nero components or not. My current method of solving this is messy: $NeroIsDetected = 1 ; Assume Nero is present on the PC by default Sleep(5000) ; Give the cleantool a few seconds to discover stuff While 1 If WinExists("Browse for Folder") Then ;Nero does not exist $NeroIsDetected = 0 NeroIsNotOnThisComputer() Exitloop Else If WinExists("Nero General CleanTool") And $NeroIsDetected Then ;Nero Exists UninstallNeroStepByStep() ExitLoop Else Sleep(100) ; wait a bit longer for a window to appear EndIf EndIf WEndoÝ÷ Ø-êÞi·µêðk"7ök§ªiË+^²©eÉ˳¶¬±Êâ¦ÙÞyÛ-¢»§¢{½êÚjz[(|ðÛ(¶ç©çM4¬zÚ(²+¶í¢h§tývX¤zÚ zÚâvâ¶'é¢Ë"nW¿ªê-zëÙbo¨%¡¶¥½ªâi¹^±ëm¢Ëqë,§¢w¨~Ø^Â)Ý£)¢©jëh×6 Global $success = 0 AdlibEnable("WaitWindows") Switch $success case 1 ;... case 2 ;... Case else Sleep(100) Wend ;... Func WaitWindows() If Winexits("windows1") Then $success=1 If Winexists("windows2") Then $success=2 EndFunc PS script not tested
Valuater Posted September 12, 2006 Posted September 12, 2006 (edited) just missing the "While" Global $success = 0 AdlibEnable("WaitWindows") While 1 Switch $success case 1 ;... case 2 ;... Case else Sleep(100) Wend ;... Func WaitWindows() If Winexits("windows1") Then $success=1 If Winexists("windows2") Then $success=2 EndFunc Edited September 12, 2006 by Valuater
jpm Posted September 12, 2006 Posted September 12, 2006 (edited) just missing the "While" Global $success = 0 AdlibEnable("WaitWindows") While 1 Switch $success case 1 ;... case 2 ;... Case else Sleep(100) Wend ;... Func WaitWindows() If Winexists("windows1") Then $success=1 If Winexists("windows2") Then $success=2 EndFuncThanks A lot for the correction edit a typo in the script Edited September 13, 2006 by jpm
nikink Posted September 13, 2006 Author Posted September 13, 2006 (edited) How does that adlibenable solution compare to Do Sleep(50) Until WinExists("window1") Or WinExists("Window2") If WinExists("window1") Then ... If WinExists("Window2") Then ... Are these equivalent? Is one more efficient or objectively better in some way? Just curious, and seeking understanding... B-) Edited September 13, 2006 by nikink
sohfeyr Posted September 13, 2006 Posted September 13, 2006 How does that adlibenable solution compare to Do Sleep(50) Until WinExists("window1") Or WinExists("Window2") If WinExists("window1") Then ... If WinExists("Window2") Then ... Are these equivalent? Is one more efficient or objectively better in some way? Just curious, and seeking understanding... B-) Yours is a synchronous solution, while the function pointed to in AdlibEnable would run asyncronously with the rest of the script. On the off chance you meant for the Do...Until...If solution to be the adlib function, the Do...Until part is unneeded, as Adlib automatically loops and waits an interval. Mine:Time Functions - Manipulate the system clock! | WinControlList (WinGetClassList++) | .Net Setup Wrapper, Detect or install .Net | Writing and using a VB .NET COM object in AutoItNot mine, but highly recommended:AutoItTreeViewExtension plugin | Menu code | Callback helper dll | Auto3Lib - Control the uncontrollable | Creating COM objects in AutoIt | Using .Net framework classes in AutoIt
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