Sign in to follow this  
Followers 0
Mechaflash

Checking for a named window, and wait until it terminates

13 posts in this topic

I know this function exists... cause I remember seeing it.. but looking at the function list twice, I missed it both times.

What's the function to check for a window (by name of window), and also conditionally pause the script until the window terminates?


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This is what you are looking for.

WinWaitClose ( "title" [, "text" [, timeout]] )

which can be found @: Function Reference > Window Management

Edited by Aipion

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi, Mechaflash213, I believe you're looking for WinExists. Something like this maybe?

While WinExists("Untitled", "")
MsgBox(0, "", "Yep!")
Sleep(1000)
WEnd

Edit: more than one way to skin a cat. Aipion's works as well :)

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Thanks Aipion and JLogan for the quick reply.

@Aipion would it matter that it's not checking for the window first, and just carrying out the command?


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

It does do a check, if the window does not exist when it checks, it simply moves on to the next command.

WinWaitClose("Untitled", "")
MsgBox(0, "", "Gone")

If the window does not exist, it will go right to the Message Box. If the window does exist, it will pause until the window is closed.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I would say make sure the window Exists with WinExists then go with WinWaitClose.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

The difference is really in what you want to do. Using a While statement with WinExists, you can do other stuff while you wait for the window to close. With WinWaitClose, however, the script pauses completely until that condition is met.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I have a good one for you: how do you check it by the Class of the window?


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

While WinExists("[CLASS:Notepad]", "")
MsgBox(0, "", "Yep!")
Sleep(1000)
WEnd


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Code the script like this:

While 1
   Sleep(100)
   If WinExists("title", "") = 1 Then ExitLoop
WEnd
WinWaitClose ( "title" , "" )

This Code will check if the window Exists then it will wait until it terminates.

Edited by Aipion

Share this post


Link to post
Share on other sites

@Admiral. Sorry, I overlooked the link in the documentation. I'll make sure to be a perfect robot and not make a human mistake, like overlooking a detail, next time.


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

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