shiv Posted March 13, 2014 Share Posted March 13, 2014 For $i = 1 To 10 If WinExists("My window") Then ControlClick("My window","NO","[CLASS:Button; INSTANCE:1]") Sleep(2000) WinWaitActive("Check your window","test: yahoo.com",2) ControlClick("Check your window","test: yahoo.com","Button2") ExitLoop EndIf Sleep(1000) Next Some time "My window" is pop up 1 time and some time it is pop up twice. The above code handle this window "My window" successfully for the 1st time its thrown but when it occurs 2nd time it unable to handle it. Please provide some refactoring for the above code so that it can handle the pop up window "My window" 2 times Link to comment Share on other sites More sharing options...
JohnOne Posted March 13, 2014 Share Posted March 13, 2014 while 1 If WinExists("My window") Then ControlClick("My window","NO","[CLASS:Button; INSTANCE:1]") Sleep(2000) WinWaitActive("Check your window","test: yahoo.com",2) ControlClick("Check your window","test: yahoo.com","Button2") ;ExitLoop EndIf Sleep(1000) wend AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
shiv Posted March 14, 2014 Author Share Posted March 14, 2014 Hi John thanks a lot, But suppose if window "My Window" is not pop up , not for once then for how long would it wait for the window to exist. And if window not exist then would it get stuck there or will execute my code further. Actually in my application this window occurs after 2 days. so i just want to write a code which checks the presence of this window. if the window exist then it can handle it .(here the probability of occurring the window is 2 times) thanks Link to comment Share on other sites More sharing options...
NewPlaza Posted March 14, 2014 Share Posted March 14, 2014 (edited) The code above will wait 1 second.... Then loop again... But if it does find 'MyWindow' then it will wait a maximum of 4 seconds for 'CheckYourWindow' to be active. Edited March 14, 2014 by NewPlaza Link to comment Share on other sites More sharing options...
shiv Posted March 14, 2014 Author Share Posted March 14, 2014 Its not only about that how long would it wait. PLEASE go through again my query above Link to comment Share on other sites More sharing options...
NewPlaza Posted March 14, 2014 Share Posted March 14, 2014 (edited) How often do you run that bit of code? Edited March 14, 2014 by NewPlaza Link to comment Share on other sites More sharing options...
JohnOne Posted March 14, 2014 Share Posted March 14, 2014 Most code has a main while loop. In the absence of solid information about when and when not your target window appears twice or how long you're prepared to wait for a second window, logic suggests you check for it infinitely in that main while loop. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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