Sign in to follow this  
Followers 0
noob27

tutorial code fails for me

5 posts in this topic

all,

at the risk of looking like a fool, I need to find out what went wrong ... ;)

I discovered AutoIt two hours ago and I'm struggling to get started. even sample code fails for me:

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

the above hangs on the second WinWaitActive line (adding a timeout parameter works with the expected delay). I can make it work when I change this line to:

WinWaitActive("Notepad", "Do")

"Do you" or any other substring out of notepads save dialog window seems to fail again.

and last but not least: every script that hung left a process running - I had to use taskmanager to kill about 20 autoit processes :blink:

is this a noob problem, is it my environment (win7 64bit, english OS, but non english regional settings) or what???

AtDhVaAnNkCsE

Share this post


Link to post
Share on other sites



Change this line WinWaitActive("Notepad", "Do you want to save") to this WinWaitActive("Notepad"), and it'll probably work. Notepad's exit dialog box has changed since that tutorial was written..


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

noob27,

Welcome to the AutoIt forum. :blink:

Someone else asked exactly the same question a few minutes ago - so you will find your answer here. :P

Hanging scripts will continue to run. You can kill them by using the <Tools - Stop executing> menu option in SciTE, or via the tray icon menu - no need for Task Manager.

Weel done for working through the Help file - the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page).

Enjoy AutoIt. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

whoa - helpful gang here!!

thanks a lot for the fast answers.

I found out (too) that it's the second parameter that blocked me and omitting it certainly helps, but ...

that's bad news, right? the reason to use that string is to find out if I'm getting the expected dialog. If notepad ever ;) asks me "do you want me to stop formatting your system disk now" and I blindly confirm with ALT-N... :blink:

so how do I find out what dialog text I can use to identify the correct window? can I only use strings that are visible thru the autoit window info tool? why does "Do" work while "Do you" and "you" fail? what's the difference? is that a notepad specific problem? do I better expect this kind of surprises in other (even all?) applications?

notepad seems to be such a simple / vanilla application and failing tutorial code scares me a BIT.

and thanks for the tutorial/wiki pointers - that will keep me busy for a lil' while :P

Share this post


Link to post
Share on other sites

That is a very basic example, and not all windows expose their innards to third party applications, and some actively resist that sort of thing.

However there are numerous ways of ensuring you are interacting with the correct window.

WinTitleMatchMode option is one of those ways by setting it to use an exact match of window title.

Using the window handle is another, and even the PID of the window can be used, (both of which can be gotten in different ways).


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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