Jump to content

How to handle the window twice


shiv
 Share

Recommended Posts

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...