Jump to content

Learning to Script with AutoIt 3


LxP
 Share

Recommended Posts

  • Moderators

I still think this is a great project.

I am really just trying to keep it on the first page so people see it.

Almost as good as being a sticky.

I agree... wonder if the demi-gods will allow it :P

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Replies 127
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Great idea about the tutorial, but in my (probably bad) opinion you can learn AutoIt the best as you are practicing it. By creating scripts you're learning the best part of AutoIt scripting (one you're interested in the most f.ex. network management, game script development or general windows usage), firstly using the most basic commands, then going more and more deeply and more effective. Then you start helping other people that are having problems.

After few years of learning you become LxP and write a manual because you're tired of replying to each noob asking stupid questions (me). Nice tactics!

lol joke, yeah great thing! :P

Link to comment
Share on other sites

no problem Firefox 1.5 w/ Adobe Acrobat 7.0 Professional

kinda hijacking this thread but would anyone be intrested in a dllcalling tutorial ?

(problly rangeing from a command that takes no parameters to full blown structures)

@LXP

Great Effort, My son will appreciate this.

@wOuter

Dll Tutorial , Great Idea, I for one would appreciate that.

HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Link to comment
Share on other sites

kinda hijacking this thread but would anyone be intrested in a dllcalling tutorial ?

(problly rangeing from a command that takes no parameters to full blown structures)

I think this would be another very useful project.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

To Lxp Very good job with this tutorial :P

To w0uter if you were asking if any1 could need a tuturiol in dllcalls then i could use at utorial

Edited by rambo3889
My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! youÂ’re the best in town Fight!
Link to comment
Share on other sites

It is time this was back to the first page. Should be sticky.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Somewhat on the same subject, but a different approach, If one wanted to test one's knowledge in Autoit, I have a test engine that you can quiz yourself with. The only bad thing is this: it uses Internet Explorer, A.K.A. Internet Exploder, to run. I use this approach to train myself on topics and make sure I know the subject inside out before I have to go into a testing center to get certified.

Before I go any further, let me make one thing clear: I do not condone any braindumps being used with this engine. I make my own test from scratch, and research my materials carefully before I post any of my builds. My test will teach you the subject, NOT GIVE YOU THE QUESTIONS WORD FOR WORD. I know you can use braindumps with this, but that is a poor way of gaining knowledge. You only cheat yourself in the end.

With that said, the engine I speak of is Trandumper. I use my own customized version of it (3.3). Mine supports video among other things, that the current version will have some trouble with, and the problem with the random question, random answer has been fixed. If you would like a copy of version 3.3, let me know, and I will email it to you. I only have 1 meg on the board, so I like to keep my space as free as possible.

Currently, I haven't built a test for Autoit, but it does sound like it would be fun to do. If people wish to design questions, the format is quite simple:

1. pose your question

a. first answer

b. second answer

c. third answer

d. forth answer

answer: a

When I design questions, I use notepad to do it, and I add HTML to make the questions flow better. The sample enhanced file will tell you how to do it.

Link to comment
Share on other sites

Latest version: December 27, 2005

After seeing a few requests on the forums for help learning how to use AutoIt (and after receiving a few PMs too) I decided to start working on a document that tries to teach this. All feedback is highly encouraged.

.....(The previous version had 124 downloads)

If you have trouble viewing the PDF in your browser, please first download it by right-clicking the link and selecting Save Link As... or similar and then launch it separately from your browser.

I like what you've done. Following are points that came to me as I read your PDF.

There are those who would say that anything like this should be completely depersonalized. I think that it is fine to personalize the reader/student, but the writer should not be. Phrases like

1- "My document" would become "This document"

2- "I strongly advise" would become "It is strongly advised" or "You are strongly advised"

This is especially useful when your output is a product of collaboration with others. Since you are asking for input, the result will be a collaboration. (No, I am not looking for a name mention. It would be nice, but only if at some point, you think I have been particularly helpful. If you don't come to that point I will be happy to remain in the too numerous to mention category.)

I hope you are planning a glossary as well as an index for this work. The term "prepending" should be there. It would be good to include an overview of the best auxiliary tools available to help AutoIt coders before or after the glossary.

It would be good if you explained the Help file structure and the Pros & Cons of the Search option in the Help file.

Since you are assuming no coding experience, you should define terms like "argument", "parameter(s)" and others in a sidebar or similar construct. In the text below there may be no apparent relationship between "parameter" and "argument" to a non-coder.

Functions may or may not have a set number of parametersfor instance, there is actually a fourth argument to MsgBox() which assigns a timeout to the display of the message box. As it is an optional parameter, we have not used it. The help file states which parameters are optional for each function and what will be assumed if you do not specify them (in the case of MsgBox(), if a timeout isn't specified then the box will show indefinitely).

If a function doesn't want need any parameters at all then the brackets remain there, but are left empty:

In the last sentence above "need" would be more useful than "want".

In section 3, it would be useful to note that many programs will need both a path and an extension. (You may address this later, but I'm responding as I read it.)

I think this is a very good effort, I hope you continue it! I recommend that you have some non-coders who have little or no respect for your ego read and critique it. I also think it is a little above your stated audience. Would you consider writing it in levels, I have grouped sections together below that I think should be at a given level, and noted any variations.

Cover the items

1 What you must do before proceeding

2 Programmingit's all about values

as is, but at a slightly lower level

cover

3 Functions

4 Variables

5 Branching

6 Looping

7 Commenting

8 Arrays

twice each, first at beginner, and intermediate levels

cover

9 Combining functions on a line or

9 Using variables and functions to supply function parameters

assuming that the reader has mastered sections 3 thru 8

cover

10 Parsing files

11 Writing files

12 Editing files

assuming that the reader has mastered section 9

cover

13 Using parameter files (INI)

14 Using the registry for parameters

15 User Defined Functions (UDFs)

assuming that the reader has mastered the previous sections

cover

16 Using the included official UDFs

again, assuming that the reader has mastered the previous sections

Last, if you can build the parts of a real script (NOT BASED ON "Hello World") during the course of the tutorial, (doing part of it in each section) & tying it all together at the end, it would be great.

I look forward to your continued efforts.

Gene

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Link to comment
Share on other sites

  • Moderators

I recommend that you have some non-coders who have little or no respect for your ego read and critique it.

Articulation and grammar seem to be big points with you, so I'm sure you didn't intend that as it's read.

Although I would find it hard to believe that 'non-coders' would have 'little or no respect for' his talent, and sincere willingness to help others succeed.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks to all for the continued feedback (and for the free bumps!).

Thanks for your response Gene; I appreciate the time that you have taken to assemble it and I will take it all into consideration.

I was surprised to find that 'prepend' isn't actually a common word. I'll find another way to convey what I mean.

It would be good if you explained the Help file structure and the Pros & Cons of the Search option in the Help file.

Do you have any particular suggestions in mind here? At this stage I only rely on the help file for its Hello World tutorial and its function reference.

Since you are assuming no coding experience, you should define terms like "argument", "parameter(s)" and others in a sidebar or similar construct. In the text below there may be no apparent relationship between "parameter" and "argument" to a non-coder.

Agreed. I should also be more careful so as not to alternate between the two in the same sentence.

I recommend that you have some non-coders who have little or no respect for your ego read and critique it.

I can only hope for honest opinions. No one needs to be afraid of offending me by pointing out that some facet of my work is very below par -- I need to know this if it's to be improved.

Last, if you can build the parts of a real script (NOT BASED ON "Hello World") during the course of the tutorial, (doing part of it in each section) & tying it all together at the end, it would be great.

This is a tricky one as it probably requires that all of the material be written first; I'm open to ideas for such a finished script in the meantime though.
Link to comment
Share on other sites

If a function doesn't want need any parameters at all then the brackets remain there, but are left empty:

It seems that parentheses "()" and brackets "[]" are used interchangably in the AutoIt help file (and perhaps within the programming community as well). It might be nice to reserve the term brackets for the discussion of optional parameters. How many new users have you seen do this?

WinActive ( "Notepad" [, "text"] )

So a new user might think:

I need one parameter, but not all of them, should I keep the brackets?

WinActive ( "Notepad" [] )

@LxP,

Keep up the good work. Thanks you for considering/incorporating "the answers" into this document. Those with limited English skills might not have understood each nuance of your exercise instructions.

I see a book deal coming :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Articulation and grammar seem to be big points with you, so I'm sure you didn't intend that as it's read.

Although I would find it hard to believe that 'non-coders' would have 'little or no respect for' his talent, and sincere willingness to help others succeed.

I have written a number of training documents. Over time I have found that many friends/acquaintances will refrain if at all possible from pointing out your errors. They don't want to hurt your feelings. Respect for talent often equates to awe. In that case the respectful reader may believe that their lack of understanding is due to their own ignorance or stupidity. Then you get nice responses of little value. My initial statement "I recommend that you have some non-coders who have little or no respect for your ego read and critique it." stands. :P

Gene

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Link to comment
Share on other sites

Thanks to all for the continued feedback (and for the free bumps!).

Thanks for your response Gene; I appreciate the time that you have taken to assemble it and I will take it all into consideration.

I was surprised to find that 'prepend' isn't actually a common word. I'll find another way to convey what I mean. A couple of simple, but disimilar examples often work great. You could also place an assumptions page at the beginning of each section, and cover key but unintuitive items there. Not too many or the reader may be intimidated.

Do you have any particular suggestions in mind here? At this stage I only rely on the help file for its Hello World tutorial and its function reference. Many people type search strings that are either too cryptic or too verbose. When either no hits are returned or so many they can't find the right one, too many give up on searching.

There is also the problem of no fuzzy logic. If the keyword is "GUIGetMsg" and all you can remember is "GetMsg" the search won't find it.

Agreed. I should also be more careful so as not to alternate between the two in the same sentence.

I can only hope for honest opinions. No one needs to be afraid of offending me by pointing out that some facet of my work is very below par -- I need to know this if it's to be improved.

This is a tricky one as it probably requires that all of the material be written first; I'm open to ideas for such a finished script in the meantime though.

Below are some code examples. They are my variations on a code snippet by Michael Curley. My purpose is not to get you to use them per se, but to get you to consider using this type of example scenario to demonstrate that any piece of logic can be applied in many ways and that functions also can be applied in many ways. Newbies in any endeavor often see single examples of a concept as THE CORRECT WAY. Sometimes it is much later that they realize the multiplicity of ways.

Initial snippet...

For $i = 0 to UBound($Array)-1
  IF $Array[$i] = $Whatever Then
    DoWhatever()
  Else
  ;DoNothing!
  EndIf
Next

Some variations on Michael Curley's theme

Subject: Compare/match a Variable with/within/beginning/ending of each element of a Array

To use a UDF from the include library try...

_ArrayBinarySearch - Uses the binary search algorithm to search through a sorted 1-dimensional array.

#include <Array.au3>

$FoundIndex = _ArrayBinarySearch ( $Array, $Whatever )
Select
  Case @error = 0
    DoWhatever()
  Case @error = 1
    MsgBox(0,"Error Message","$Array isn't an array.")
  Case @error = 2
    MsgBox(0,"Error Message","$iKey is out of bounds.") ; I'm suspicious of this error message.
  Case @error = 3
  ;DoNothing!
Endselect

Search for "_ArrayBinarySearch" in the Help File

or

_ArraySearch - Finds an entry within an one-dimensional array. (Similar to _ArrayBinarySearch() except the array does not need to be sorted.)

#include <Array.au3>


$FoundIndex = _ArraySearch($Array, $Whatever)
Select
  Case @error = 0
    DoWhatever()
  Case @error = 1
    MsgBox(0,"Error Message","$Array isn't an array.")
  Case @error = 6
  ;DoNothing!
Endselect

Search for "_ArraySearch" in the Help File

To find/compare a variable to text within an array element, try...

For $i = 0 to UBound($Array)-1
  IF StringInStr ( $Array[$i], $Whatever ) Then
    DoWhatever()
  Else
  ;DoNothing!
  EndIf
Next

Search for "StringInStr" in the Help File - Note that the StringInStr function has options for casesense and (occurance within the array element).

To find/compare a variable at the beginning of an array element, try...

For $i = 0 to UBound($Array)-1
  IF $Whatever = StringLeft ( $Array[$i], _
     StringLen ( $Whatever ) ) Then
    DoWhatever()
  Else
  ;DoNothing!
  EndIf
Next

Search for "StringLeft" in the Help File

To find/compare a variable at the end of an array element, try...

For $i = 0 to UBound($Array)-1
  IF $Whatever = StringRight ( $Array[$i], _
     StringLen ( $Whatever ) ) Then
    DoWhatever()
  Else
  ;DoNothing!
  EndIf
Next

Search for "StringRight" in the Help File

-----Original Message-----

From: AutoItList@yahoogroups.com [mailto:AutoItList@yahoogroups.com]On Behalf Of Michael Curley

Sent: Tuesday, January 03, 2006 9:13 AM

To: AutoItList@yahoogroups.com

Subject: RE: [AutoIt] Compare a Variable with all elemenst of a Array

Edited by Gene

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Link to comment
Share on other sites

yes.

sorry, was doing the one word thing as a joke because of another post, but then i realized that others may not get it, 'cause i'm a dork. anyway; yes you can open it without acrobat, BUT you would still need to download another .pdf reader or DLL (if you wanted to do it programtically) but since it's the same amount of work and acrobat is free....
Link to comment
Share on other sites

i guess without using any programs its impossible to do,so which of these programms requires less space? :lmao:

i really have no clue on that one. I honestly don't remember the last time i worried about the size of a program before installing it, with the obvious exception of the multi-gig games that i buy :P
Link to comment
Share on other sites

  • Moderators

sorry, was doing the one word thing as a joke because of another post, but then i realized that others may not get it, 'cause i'm a dork. anyway; yes you can open it without acrobat, BUT you would still need to download another .pdf reader or DLL (if you wanted to do it programtically) but since it's the same amount of work and acrobat is free....

By my calculations, your entitled to at least 3759 characters in a post... you didn't have to stop at the 'yes' :P

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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