Jump to content
Sign in to follow this  
Aratorin

New User Trouble Please Help!

Recommended Posts

Aratorin

Ok, so I just started using Autoit today. I'm going through the tutorials, and I'm stuck on the second one. My script looks like this:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.12.1
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
Send("!n")

But when I run it, it gets stuck at the save dialog and won't go any further:

Posted Image

Any idea what I'm doing wrong? I compared my script to the tutorial script, and it looks exactly the same to me. I even tried modifying "Do you want to save" to "Do you want to save changes to Untitled?", but that didn't work. If it matters, I'm running Vista Home Premium 64bit, and I've tried running the script as both x64 and x86.

Edited by Aratorin

Share this post


Link to post
Share on other sites
Aratorin

Try getting the title of the window dialog using the AutoIt Window Info tool as the tutorial suggests.

I did that. The title of the information window is Notepad. For some reason it seems like the script is never recognizing that the info window is active.

Share this post


Link to post
Share on other sites
jvanegmond

Maybe you can try this:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")

$InitActive = WinGetHandle("[active]") ; Gets the current active window
WinClose("Untitled - Notepad")
While WinGetHandle("[active]") == $InitActive ; Compare that window against the window that is active now
    Sleep(100) ; Do nothing while it doesn't show up
WEnd

WinWaitActive("Notepad", "Do you want to save")
Send("!n")

Maybe a little advanced, but it will fix the problem probably.

Share this post


Link to post
Share on other sites
Aratorin

I actually got it to work by changing WinWaitActive("Notepad", "Do you want to save") to WinWaitActive("Notepad"). Is there any reason autoit wouldn't be able to detect the text in the dialog box? Is this a known issue with 64 bit or Vista?

Share this post


Link to post
Share on other sites
TunaSalad

In my experience with the WinXXXXX functions like WinClose, WinActivate. WinExists, etc... the TEXT parameter you can optionally pass in never worked well for me so I never use that argument, on top of the fact that most of time I need to write language independent scripts and therefore can't hardcode English (or any other language) strings.

So I'd suggest you to replace the following line:

WinWaitActive("Notepad", "Do you want to save")

for this one

WinWaitActive("Notepad")

EDIT: Added code Tags

Edited by TunaSalad

Why crabs don't give money to charity..... because they are shell-fish!! PS: Don't be a crab and share your scripts with the community! ;-)

Share this post


Link to post
Share on other sites
Cw2K1

Please always use Code Tags while posting your codes :P


Enjoy the complexity.Feel the power of simplicity.

Share this post


Link to post
Share on other sites
crouzilles

Hi all.

I know this topic is over 2 years old, but I believe any new info one comes across should always be shared.

So me too I am new to AutoIt, and me too I came across this problem.

But by using the "AutoIt Window Info tool", I discovered that if I click on the "Visible text" tab, I only get "&Save" "Do&n't Save" and "Cancel" options, but I don't get the phrase "Do you want to save changes to Untitled?"

I believe this phrase is actually more like an image and not really text, this is why AutoIt cannot recognise it as a text element.

I am very happy to be proven wrong on this of course.

Yours sincerely

Crouzilles

Edited by crouzilles

Share this post


Link to post
Share on other sites
kylomas

aratorin,

just ran the code as posted and worked perfectly.

WinXP SP3

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.