Jump to content

Don't get the helpfile at all


Recommended Posts

I'm having a real trouble understnading this. I am english and my first language is english, but this help file isn't english enough. It briefly explains something then puts the code in. I'm not blaming it on the helpfile, it's just not explained enough for me anyway, plus I'm not Mr.Intelligent Man! or anything. So if someone could explain just a little bit about anything I'm having trouble with. You don't have to "easy" all of it, just a line I'm having touble with then someone else does another line. If I can understand this first introduction section then I should be able to work my way up from there.

When you start AutoIt you will be asked to open a script file. Understand

A script file is a simple text file containing AutoIt keywords and functions that tell AutoIt what you want it to do. Understand

Script files are created in a simple text editor such as notepad.exe or a much better alternative. Understand

Although AutoIt v3 scripts are just plain-text files they are usually given the file extension .au3 to help tell the difference between a script and a text file. Understand

If you used the full installer to install AutoIt you can execute an AutoIt script simply by double-clicking it. Understand

There are also various options to open, edit, or compile a script if you right-click on the .au3 file. Understand

Here is an example script. Notice that ; is used for comments (much like REM in DOS batch files): Understand

; This is my first script
MsgBox(0, "My First Script!", "Hello World!")
Understand

More complicated scripts may use functions, which are usually placed at the end of a script. Here is a similar script using functions: Do not understand What is a function? Why are they here? What do they do?

; This is my second script (with functions)
MsgBox(0, "My second script!", "Hello from the main script!")
TestFunc()

Func TestFunc()
    MsgBox(0, "My Second Script!", "Hello from the functions!")
EndFunc

The special array $CmdLine is initialized with the command line parameters passed in to your AutoIt script. Do not understand I don't get any of this sentence. What is $CmdLine, what is "initialized with the command line parameters passed in to your AutoIt script"?

Note the scriptname is not classed as a parameter; get this information with @ScriptName instead. Do not understand Again, it doesn't really make any sense.

A parameter that contains spaces must be surrounded by "double quotes". Do not understand What's a parameter?

Compiled scripts accept command line parameters in the same way. Do not understand ???

$CmdLine[0] is number of parameters
$CmdLine[1] is param 1 (after the script name)
$CmdLine[2] is param 2 etc
...
$CmdLine[$CmdLine[0]] is one way to get the last parameter...

 

So if your script is run like this:

    AutoIt3.exe myscript.au3 param1 "this is another param"

$CmdLine[0] equals... 2

$CmdLine[1] equals... param1

$CmdLine[2] equals... this is another param

@ScriptName equals... myscript.au3

 

In addition to $CmdLine there is a variable called $CmdLineRaw that contains the entire command line unsplit, so for the above example:

$CmdLineRaw equals... myscript.au3 param1 "this is another param"

 

If the script was compiled it would have been run like this:

    myscript.exe param1 "this is another param"

$CmdLineRaw equals... param1 "this is another param"

Note that $CmdLineRaw just return the parameters.

 

Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line.
Do not understand Explain the previous bits and I should be able to understand this.

AutoIt specific command Line Switches
Form1: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] file [params ...]
                Execute an AutoIt3 Script File


/ErrorStdOut    Allows to redirect fatal error to StdOut which can be captured by an application as Scite editor. This switch can be used with a compiled script.
 

To execute a standard AutoIt Script File 'myscript.au3', use the command:
'AutoIt3.exe myscript.au3'

 

Form2: Compiled.exe [/ErrorStdOut] [params ...]
                Execute an compiled AutoIt3 Script File produced with Aut2Exe.

Form3: Compiled.exe [/ErrorStdOut] [/AutoIt3ExecuteScript file] [params ...]
                Execute another script file from a compiled AutoIt3 Script File. Then you don't need to fileinstall another copy of AutoIT3.exe in your compiled file.


Form4: AutoIt3.exe [/ErrorStdOut] /AutoIt3ExecuteLine "command line"
                Execute one line of code.

To execute a single line of code, use the command:
Run(@AutoItExe & ' /AutoIt3ExecuteLine  "MsgBox(0, ''Hello World!'', ''Hi!'')"')

The tray icon will not be displayed when using /AutoIt3ExecuteLine

NOTE: Correct usage of single- and double- quotation marks is important, even double single.
Do not understand I get the normal english but when it goes code on my ays it gets really "wtf?"
Link to comment
Share on other sites

Lets start from the functions:

A function is basically a way to replace "GOTO" in other languages. Functions are defined by "Func....EndFunc" statements. Functions can be defined anywhere within the script (except within other functions), as they are not used or process until the function is "Called"

Calling a function is done by stating the Function Name followed by any parameters (may or may not exist) for the function in parenthesis

Example:

TestFunc() ;This is the call to the function, 
;when this script runs, the first (and only) thing it will do is call the function "TestFunc()"
;Notice that there are no parameters (parenthesis are empty)

Func TestFunc() ; this line tells autoit that anything between this and the next "EndFunc" statement is part of the function "TestFunc()"
    MsgBox(0, "My Second Script!", "Hello from the functions!") ; This is what will happen when you call the function, you create the msgbox that you see
EndFunc ; ends the function declaration
Link to comment
Share on other sites

Functions

Functions/User Defined Functions (UDFs) allow you to call a set of code. If you need to call many lines, it makes it easier. Also used with DLL calls and such. Have a look in example scripts, and hopefully you shall understand.

Command Line

Command line paramaters allow you to pass data to your compiled exe. So you could have myprogram.exe, and you could have switches such as /s for silent, or /? for help. That would be inputed into run for example, like C:\Path\To\Compiled\EXE\myprogram.exe /?, so the program displays a help dialouge or something. That is then accessed in your script through $CmdLine or $CmdLineRaw. You can see them in the helpfile.

@SCRIPTNAME is a Macro. Look them up in the helpfile too.

Parameters are pretty easy. Say you have a program that displays pictures in a simple GUI. You want to be able to open pictures using command line. You want a switch say /i for input file. So you run you program like so.

C:\Path\To\Compiled\EXE\myprogram.exe /I "C:\mypicture.jpg"

Both the switch and the parameter can be access through the methods mentioned in the helpfile.

The AutoIt EXE file (and compiled scripts) are able to accept parameters such as /AutoIt3ExecuteScript "file.au3".

I don't think its that hard to understand... :)

Link to comment
Share on other sites

Lets start from the functions:

A function is basically a way to replace "GOTO" in other languages. Functions are defined by "Func....EndFunc" statements. Functions can be defined anywhere within the script (except within other functions), as they are not used or process until the function is "Called"

Calling a function is done by stating the Function Name followed by any parameters (may or may not exist) for the function in parenthesis

Example:

TestFunc() ;This is the call to the function, 
;when this script runs, the first (and only) thing it will do is call the function "TestFunc()"
;Notice that there are no parameters (parenthesis are empty)

Func TestFunc() ; this line tells autoit that anything between this and the next "EndFunc" statement is part of the function "TestFunc()"
    MsgBox(0, "My Second Script!", "Hello from the functions!") ; This is what will happen when you call the function, you create the msgbox that you see
EndFunc ; ends the function declaration

"A function is basically a way to replace "GOTO" in other languages. Functions are defined by "Func....EndFunc" statements. Functions can be defined anywhere within the script (except within other functions), as they are not used or process until the function is "Called"".Understand

"Calling a function is done by stating the Function Name followed by any parameters (may or may not exist) for the function in parenthesis" - So to call a function it's TestFunc(). TestFunc is the Function Name and () is the Parameter(parenthesis)?

So for it to be a function you must add Func to the front of the Function name, followed by the parameter ()? So as you have put it Func = Function Declaration

TestFunc = Function Name

() = Parameter

Then EndFunc is to end the function.

So is a function basically a quick way to use a certain control? Meaning instead of putting "I want you to put the mouse cursor over here", it's just abbreviated to a function name, like MouseCursor, so it's a lot easier to work with the code?. ( That's just an example of what I'm trying to say)

Link to comment
Share on other sites

"A function is basically a way to replace "GOTO" in other languages. Functions are defined by "Func....EndFunc" statements. Functions can be defined anywhere within the script (except within other functions), as they are not used or process until the function is "Called"".Understand

"Calling a function is done by stating the Function Name followed by any parameters (may or may not exist) for the function in parenthesis" - So to call a function it's TestFunc(). TestFunc is the Function Name and () is the Parameter(parenthesis)?

So for it to be a function you must add Func to the front of the Function name, followed by the parameter ()? So as you have put it Func = Function Declaration

TestFunc = Function Name

() = Parameter

Then EndFunc is to end the function.

So is a function basically a quick way to use a certain control? Meaning instead of putting "I want you to put the mouse cursor over here", it's just abbreviated to a function name, like MouseCursor, so it's a lot easier to work with the code?. ( That's just an example of what I'm trying to say)

Almost.

() encases the paramaters, seperated by ","

For example

_Message ("hello", "lolololol"

Func _Message ($title, $text)
    MsgBox (0, $title, $text)
EndFunc

EDIT: Otherwise you pretty much have it down good! :)

Edited by Bert
Link to comment
Share on other sites

I would really love to help you more, but i honestly think that many of your plethora of questions could be answered if you went through the

Autoit 1-2-3 tutorial, and did a little bit more legwork in the helpfile.

Please feel free to ask any questions you may have here, but in your OP, you have about a million questions that pretty much should be common knowledge among programmers.

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