Sign in to follow this  
Followers 0
nishi

Loop while a window exists

4 posts in this topic

Hello, I'm new in this forums and with AutoIt :)

I want to create a loop that repeats the same function every 10 minutes, during the existence of a Window and, when the window be closed, stop the loop.

¿This is posible?

I tried doing this, but don't work ;)

If WinExists("WindowName, """) Then
$window = 1 Else
    $window = 0
    EndIf
While $window = 1
    Sleep(600000)
    MouseClick("left", 93, 350, 1, 15)
    WEnd

Thanks, and sorry for my bad english.

Share this post


Link to post
Share on other sites

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Hello, I'm new in this forums and with AutoIt :)

I want to create a loop that repeats the same function every 10 minutes, during the existence of a Window and, when the window be closed, stop the loop.

¿This is posible?

I tried doing this, but don't work ;)

If WinExists("WindowName, """) Then
$window = 1 Else
    $window = 0
    EndIf
While $window = 1
    Sleep(600000)
    MouseClick("left", 93, 350, 1, 15)
    WEnd

Thanks, and sorry for my bad english.

You got an infinite loop there. You see, you are not modifying the value of $window inside the loop. Your script could be reduced to this:

While WinExists("WindowName")
    Sleep(600000)
    MouseClick("left", 93, 350, 1, 15)
WEnd

Or..

AdlibEnable("_CheckWindow",600000)

While 1
    Sleep(100)
WEnd

Func _CheckWindow
    If WinExists("WindowName") Then
        MouseClick("left", 93, 350, 1, 15)
    EndIf
WEnd

You should totally follow Smoke's advice. Autoit 1-2-3 is awesome.

Share this post


Link to post
Share on other sites

Works, thanks a lot for the code and the two links, I go to read it now.

Thanks :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0