Sign in to follow this  
Followers 0
NeilClough

WinWaitActive - correct use/syntax

3 posts in this topic

Hi all,

I am going through the examples in "Learning to Script with AutoIt V3".

An example is to open and close notepad.

This code works:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("some text")
WinClose("Untitled - Notepad")
; Pick up window asking "Do you want to save changes to Untitled"
WinWaitActive("Notepad","Do")
Sleep(2000)
Send("!n")

If I try and add more text to the second WinWaitActive parameters the script doesn't find the window !!

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("some text")
WinClose("Untitled - Notepad")
; Pick up window asking "Do you want to save changes to Untitled"
WinWaitActive("Notepad","Do you")
Sleep(2000)
Send("!n")

Thanks,

Neil

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

use the window info tool as well.

it shows the visible text choices of "Save" "Dont Save" and "Cancel"

this works as expected:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("some text")
WinClose("Untitled - Notepad")
; Pick up window asking "Do you want to save changes to Untitled"
WinWaitActive("Notepad","Save")
Sleep(2000)
Send("!n")
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Hi bolthose,

Thanks for your reply.

Yes I did notice that it would work if use "Save" as text.

And just now I realize why it worked when I just had "Do" as a parameter - it is picking up the "Do" from "Don't Save" !!

Does that mean WinWaitActive will not pick up such text as "Do you want to etc etc" on a window ??

Note that as mentioned in my original post,  the "Learning to Script" document states that it should !!

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