Jump to content

WinWaitActive - correct use/syntax


Recommended Posts

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

Link to comment
Share on other sites

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

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

Link to comment
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 !!

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...