Jump to content

New User Trouble Please Help!


 Share

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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! ;-)
Link to comment
Share on other sites

  • 2 years later...

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