Jump to content

Learning To Script with AutoIt V3


BrettF
 Share

Recommended Posts

Not a problem. Hope it taught you heaps! :(

Keep on learning :)

Brett

I am new to the community and was searching for the noob section and ran across this book. I guess this is the

exact book that I need to get started. Reading most of the threads and everything seem to go right over my head.

I was second guessing my decision to go this route, but now I believe I am on the right track.

Now to sit down and get to studying. I have not read the material yet, so I can't comment on how helpful it will

be for me. However, reading the other comments, I think that I will be able to start at a level that is comfortable.

I wanted to thank you for the material before I shut everything down for my study period :) .

Thanks Brett!

Link to comment
Share on other sites

Hi, all - n00b here so please bear with me if this is already answered elsewhere.

I have AutoIt v3.3.6.0 on my PC running Vista. I'm trying to work through this tutorial and I've run into a significant issue in only the second example script. I must be the only person experiencing this problem, since I don't see any other reports of it, but I cannot imagine what I might be doing wrong.

The second example script reads (with comments removed to save space):

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

When I run this script exactly as shown here, it pauses indefinitely at the "Do you want to save" dialog and never proceeds past that point.

I believe the problem has something to do with matching the space character in the text string. If I change line 5 in the above script to read:

WinWaitActive("Notepad", "Do")

the script runs properly to completion.

But simply adding back a single space:

WinWaitActive("Notepad", "Do ")

causes it to pause indefinitely again.

Is it possible that some change has been introduced in version 3.3.6.0 that is now causing this script from your tutorial to fail? Or am I doing something boneheaded (quite possible)?

Link to comment
Share on other sites

@nEcoder- Thanks! I hope it is what you are looking for.

@Beer Slayer- Welcome to the forums!

It seems to be related to Windows 7/Vista, as the text of the window isn't the same :(

From what I could see, what you did only worked because the visible text of the window contained "Do&n't Save" and the like.

So my updated code looks like:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do&n't Save")
Send("!n")

I'm not a 100% sure what I want to do now, as it is a minor error. But on the plus side it has given me an idea for another section. Thanks :)

Cheers,

Brett

Link to comment
Share on other sites

@nEcoder- Thanks! I hope it is what you are looking for.

@Beer Slayer- Welcome to the forums!

It seems to be related to Windows 7/Vista, as the text of the window isn't the same :(

From what I could see, what you did only worked because the visible text of the window contained "Do&n't Save" and the like.

So my updated code looks like:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do&n't Save")
Send("!n")

I'm not a 100% sure what I want to do now, as it is a minor error. But on the plus side it has given me an idea for another section. Thanks :)

Cheers,

Brett

Brett, can you use Opt("Wintitlematchmode", 2) in there to solve that problem? I think that should alow it to work on all of the versions.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Brett, can you use Opt("Wintitlematchmode", 2) in there to solve that problem? I think that should alow it to work on all of the versions.

Nothing if I do it that way. Grrrrr.
Link to comment
Share on other sites

Nothing if I do it that way. Grrrrr.

Must be the work of that drunk monkey.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Brett and all - thanks for the quick responses!

It seems to be related to Windows 7/Vista, as the text of the window isn't the same :(

Isn't the same as what? Does this exact same script work in Windows XP or Windows 7?

This particular example is identical to the one in AutoIt's own help file, and the dialog on my screen looks exactly the same (pixel for pixel) as the one shown in that help file (my own screenshot is below). The screenshot used in AutoIt's help file was obviously taken from a computer running Vista (or possibly Win7 - I don't know what the dialog looks like there). The script example in the help file is the same as the one you give in your tutorial, and of course both fail in the same manner.

This is the dialog in question on my computer:

Posted Image

I find myself wondering if it ever worked as described - if the folks who wrote the help file ever actually tried the script in question. Is the OS version even a factor?

From what I could see, what you did only worked because the visible text of the window contained "Do&n't Save" and the like.

Entirely possible. I don't know that the space was the problem, but it seemed logical given the results I got.

So my updated code looks like:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do&n't Save")
Send("!n")

This does work - thanks! But I'm still concerned that some functionality may have been lost... does this imply that it's not possible to match the actual text in this dialog, but only the text of the buttons/controls?

Have we found a bug in AutoIt v3.3.6.0?

Edited by beerslayer
Link to comment
Share on other sites

This does work - thanks! But I'm still concerned that some functionality may have been lost... does this imply that it's not possible to match the actual text in this dialog, but only the text of the buttons/controls?

Have we found a bug in AutoIt v3.3.6.0?

There's no bug. If you start Au3Info you would see that the text is simply not seen. Look further and you would notice the DirectUIHWND class, which doesn't work like a normal control.

Just work around it.

Link to comment
Share on other sites

There's no bug. If you start Au3Info you would see that the text is simply not seen. Look further and you would notice the DirectUIHWND class, which doesn't work like a normal control.

Just work around it.

It seems odd to me that they would use this exact example, complete with a Vista/Win7 screenshot, in the tutorial in AutoIt's own help file when it clearly does not work.

At the very least, we've found a bug in the documentation (and in this tutorial) that really, really ought to be fixed ASAP. A tutorial, of all places, is a very bad place for such an oversight.

Link to comment
Share on other sites

  • 2 months later...

Learning To Script with AutoIt V3

Document was last updated 17 February 2010

This document is for you if you are interested in learning to script with AutoIt. Where possible, I will try to assume that you have no prior coding experience and I aim to teach you some good general coding habits, which will be beneficial should you decide to move on to other languages.

Download here

Learning to Script with AutoIt V3 (Last Updated 17 Feb 2010).zip(Previous Versions = 10152)

The download contains the tutorial, example AU3 files contained in the text, printable exercise question/answer sheet and more.

If you encounter any issues, with the text, please post them, but this is not a thread for requsting help or requesting scripts. Please do not PM me either. We have this wonderful support forum, so use it! :mellow:

Original Document: Alex Peters (LxP)

http://yallara.cs.rmit.edu.au/~apeters/

Updated By: Brett Francis (BrettF)

http://signa5.com

Thank you for this. Really appreciate all the learning resources you guys have assembled.
Link to comment
Share on other sites

Link to comment
Share on other sites

  • 4 months later...

Well send it over here instead.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...

Hi wangnjj,

Apologies for my late reply, I have been very busy as of late.

I see I made a few slip ups there. Noted in my copy, and will release when I have the time.

Cheers!

Brett

Link to comment
Share on other sites

i'm sorry for my newb question, maybe this is a really silly question. Is the tutorial in .PDF? cuz i can't open it with acrobat reader. thx in advance

The download is a ZIP file, but the main content is in PDF format.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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