I translated , so people wont have any lame excuses for not releasing something themselves.
I learned it using this Tutorial, and hey, if I can do it, you cant do it.
Note that I'll translate one Chapter each day, since I got other stuff to do, too. Also, I edited it a bit to make it easier to understand in english, and I also deleted some unnecessary stuff.
(Yes, I know I should post this in the Tutorial-Section, and I will once I'm done translating it all, but GODDAMN I want the lazy people in this section to get off their lazy butts. :P)
__________________________________________________ ______
This Tutorial was written by MaZze from cpg and in my opinion the best TuT to learn AutoIT.
__________________________________________________ ____________
[AutoIt] BASICS I
Vorwort :
A few weeks ago I started learning AutoIT. Sadly, most Tutorials were written in "NerdLanguage", so normal people had no chance of understanding anything.
So in order to make it easier for people to start with AutoIT, I'm writing this Tutorial.
__________________________________________________ ____________
FIRST STEPS :
- Download AutoIT (Newest Version)
That would be :
(Note by Dark Raccoon: I recommend downloading the newest SciTE, too. Link: .)
- Take a look at the program
(Just start it and try out a few functions.)
__________________________________________________ ____________
Writing our first Program :
First I'll show you the whole Code, then I'll explain it step-by-step.
Start the AutoIT SciTE Script Editor.Quote:
Run ("notepad.exe")
Send ("Now we are writing the text...")
Send ("{enter}")
Send ("Of course we could do it ourselves...")
Send ("{enter}")
Send ("But thats what AutoIT is for!")
Sleep (5000)
Send ("!{F4}")
Sleep (1000)
Send ("{right}")
Sleep (1000)
Send ("{enter}")
Exit
(If its your first time coding, there should be a blank project.)
__________________________________________________ ____________
Now lets take a look at the Commands :
I started with
("notepad.exe").
Run ("Filename")
It is important to write the Filename as "filename.fileformat".
In AutoIt, most Filenames, Messages, ... are written within the " signs.
Otherwise they are just meaningless Letters and Numbers.
(Thats not always the case, but for our example the " signs are very important.)
In our example its "notepad.exe".
Since Notepad is a common program, we dont need to put write an specific directory.
Of course, there are exceptions.
For example, if the File is in the same Folder as your script/program, then you dont have to write their directory.
However, for any other programs/files it is recommended to write their directory.
__________________________________________________ ____________
Now for the Command we used the most : Send
Send ("text")
or
Send ("{key}")
With this command, you simply send text or keys.
The following is very important :
When you want to send Text, write :
Send ("text")
If you want to send Keys (strg/alt/esc/enter/etc) write :
Send ("{key}")
It is important for both that you always have to make your that your text is within the "-signs.
Otherwise it wont work.
Of course, we can combine both. For example, it wouldnt be a problem to write :
Send ("blah blah{Enter}blah blah{Left}{Delete}{Right}{Enter}blah blah")
At the end I will also give you a list of some Keys.
__________________________________________________ ____________
The next Command is Sleep :
Sleep (1000)
Sleep (time to wait)
With Sleep, you can easily pause programs or let them rest for some time.
Its really important that you write the time to wait in milliseconds.
So basically :
1000 = 1 second
I used that command so you can watch the program write.
(Otherwise it would be finished before you even know whats happening.)
__________________________________________________ ____________
Now lets take another look at Send
Send ("text/{key}")
It is also possible to use Key-Combinations.
In the example I used the combination ALT+F4, so the opened window closes.
In AutoIT, the keys CTRL and ALT got "special signs".
Alt = !
CTRL = ^
So I wrote :
Send ("!{F4}")
__________________________________________________ ____________
Now finally, the end of our Script.
We symbolize the end with:
Exit
With this command, you simply close your script/program.
It doesnt have to stand at the end of a script.
You could, for example, combine it with other commands.
(If/Else - HotkeySet - etc.)
__________________________________________________ ____________
Now its time for the list I told you about.
(I'll just write down the ones that are used the most.)
For now, you wont need anything else than this.Quote:
! = alt
^ = ctrl
{Enter} = Enter
{Delete} = delete
{left}{right}{up}{down} = arrow keys
{F1}/..../{F12} = F1 - F12
__________________________________________________ ____________
IMPORTANT :
AutoIt-Projects (source-files) are always saved as *.au3 Files!
NEVER save it directly as a *.exe!
Thats what the Compiler is for.
__________________________________________________ ____________
[AutoIt] Basics II
What are we gonna do today?
I think its time for variables.
__________________________________________________ ____________
What are "Variables"?
A Variable is nothing but a "Spaceholder".
In some Scripts, certain values are used over 1000 times.
So why write like hell on the SourceCode, if you could just take a "shortcut"?
In AutoIT, Variables are marked by the $(dollar)-sign.
That way, AutoIT knows that your talking about a Variable, and not abou ta command etc.
__________________________________________________ ____________
How is a Variable build?
A Variable is build really simple:
$variable = value/"value"
The following is really important when using variables:
AutoIT notices Capitalization in variables!
So...
$Variable = 10
$VaRiabLe = 10
$vAriabLe = 10
arent the same!
Try to always write variables small, so there wont be any trouble
.
__________________________________________________ ____________
What can I name a Variable?
As long as theres a $-Sign in front of it, almost everything should be okay.
However, there still are some exceptions.
Signs like !"§$%&/()=? etc cant be used to name a Variable.
Same thing with äöü and ÄÖÜ
__________________________________________________ ____________
Of course you can also combine text and/or other variables.
That way, you dont have to always write another Send() command.
To combine a variable with a string (Thats the text between the "-Signs), you need this sign:
&
A correctly combined Text would look like this:
Result => Text number 1Quote:
$variable = "number 1"
Send ("Text " & $variable)
(correct)
As you can see, I only wrote the Text within the "-Signs.
Thats because AutoIT recognizes everything that is written in "-Signs as a String, and not as a Variable.
So if you write this:
The Result would beQuote:
$variable = "nummer 1"
Send ("Text & $variable")
Can you see what would have happened?Quote:
Text & $variable
AutoIT would just have written the just within the "-Signs as Text, and not how we would have wanted it.
__________________________________________________ ____________
Heres an Example how you could use Variables.
Example (Without Variables):
Image you would want to send a Mass-Email.
However, you want to send that Message to 3 different people.Quote:
Send ("Hello Kevin,")
Send ("{Enter}")
Send ("I will make a party at xx.xx on Friday.")
Send ("{Enter}")
Send ("I would appreciate it if you would come.")
Send ("{Enter}")
Send ("Oh, and Kevin, it could get pretty late, so tell your parents..")
Send ("Greetz, Eddy")
Wanna type it all again?
No way! Lets just use variables...
Example (With Variables):
Quote:
$friend1 = "Kevin"
$friend2 = "Tom"
$friend3 = "Jesus"
$friend4 = "Anne"
Send ("Hello & $friend1,")
Send ("{Enter}")
Send ("I will make a party at xx.xx on Friday.")
Send ("{Enter}")
Send ("I would appreciate it if you would come.")
Send ("{Enter}")
Send ("Oh, and Kevin, it could get pretty late, so tell your parents..")
Send ("Greetz, Eddy")
In this case, you would just have to exchange the name of the variable and our Mass-Email would be finished.
Now you know about Variables.
Its very important that you know about them, because without Variables coding would be hell.
___________________________________
(I completely rewrote this part since that was faster and easier than translating all the stuff he wrote.)
Mouse Commands -
Code:
MouseMove - Move the Mouse to certain Coordinates on your Screen. MouseClick - Make the Mouse click a certain Point. MouseClickDrag - Make the Mouse click and drag something.
Note: You can find out the x and y coordinates of certain points by using the AutoIT Window Info, which comes with the default installation. Do not forget that the Coordinates may vary depending on your Resolution.AutoIT Window Info
Lets say we want to move our Mouse from the left to the right.
- Start the AutoIT Window Info.Now comes the Coding:
- Switch to the "Mouse"-Section.
- Click and Drag the Finder Tool to the very right of your Screen.
- Write down the x and y Coordinates on a sheet of paper.
We want to move our Mouse, so we take the command "MouseMove".
Code:
MouseMove (xcoordinate, ycoordinate, speed)
Code:
MouseMove (1437, 453)
Thats how you make your Mouse move.
You can also combine the MouseMove-Command with other Functions such as PixelSearch, Imagesearch, and so on.
____________________________________________
Now we want the Program to - for example click the Start-Button in our Taskbar.
For this, we use the commad "MouseClick".
Code:
MouseClick ("button", xcoordinate, ycoordinate, clicks, speed)
Clicks: How often is it supposed to click that point?
Speed: How fast do you want it to click?
So, you start the AutoIT Window Info and get the Coordinates of your Start-Button.
In my case, the Code would look like this:
Code:
MouseClick ("left", 30, 886)
That way, it will only click once and by default Speed.
Just as with "MouseMove", you can combine this command with other functions.
_________________________________________
Now we are almost almost done.
Lets say we want our program to click&drag a File onto our Desktop.
We will use this Command:
Code:
MouseClickDrag ("Button", xcoordinate one, ycoordinate one, xcoordinate two, ycoordinate two, speed)
Open up the AutoIT Window Info and get the coordinates of your files.
Write them down and get the coordinates of where you want to drop them, and write those down, too.
In my case, the code looks like this:
Code:
MouseClickDrag ("left", 321, 296, 1208, 501)
And just like with the other Mouse-Commands, you can combine this one with other functions.
So thats it for Mouse-Commands.
Tomorrow I'll tell you about some Pixel-Functions as well as Message-Boxes.
- Tutorial will be continued tomorrow at this point.