Zisly
Intermediate OT User
- Joined
- Jun 9, 2008
- Messages
- 7,338
- Reaction score
- 120
In the first tutorial I talked about message boxes, which isn't that funny.
So now I will explain something a but more interesting (I hope).
So let's begin.
As I didn't mention how to comment your code in AutoIt in the first tutorial I will do it now, as commenting your code is quite important or else you can get totally lost when you don't understand what that functions does and so on.
So if when you comment your code you just type: ; and then write whatever you want.
Ex:
Now the code is commented , now I will go over to the loops.
The While is the beginning of the loop and the 1 is the expression.
The 1 means that the loop will continue until expression is false.
If you would put a 0 it will loop until the expression is true.
The Wend must always added if a While statement is declared.
Well that covers the loop, at least the basics of it
Now I will learn you how to make a hotkey and how to make the script/program click for you
Here is the code:
Now I have putted some comments in the code so it's easier to understand.
The HotKeySet("{F4}", "ExitProg") means that we set F4 as a hotkey to the function ExitProg.
And the other sets it to start function.
Ok, as we don't want the script to just end instantly we need to make a loop which will wait for a function call.
Well, I don't need to take up the loop part again so I will explain what the sleep(100) does.
Some of you might know what it does, but I will explain it anyways, the sleep is like a pause period which you can set to whatever you want.
You set the time in milliseconds , which means 1000 = 1 sec.
Now the loop will continue until a function is called ( waits for you to press F3 or F4).
Now we will go to the functions which are quite simple .
A function always start with Func followed by the functions name, which is StartProg in this case.
Below that goes the code, which now is the mouse click.
We begin with the loop.. and then we put what it should do.
MouseClick("left") means that it will left click where the cursor is situated, you can change it to right if you want.
As you can see I have putted a little pause/delay between the clicks so it wont click too fast, in this case I took half a sec which is 500 in milliseconds.
Now we put the Wend and below that the EndFunc which means thats the end of that function.
Now we just have the ExitProg function left, which is very simple.
The Exit 0 simply just exit/terminate the program.
Hope you could understand the tutorial, as I'm not that great explaining things
Please comments
If you think it's use full give reputation please!
So now I will explain something a but more interesting (I hope).
So let's begin.
As I didn't mention how to comment your code in AutoIt in the first tutorial I will do it now, as commenting your code is quite important or else you can get totally lost when you don't understand what that functions does and so on.
So if when you comment your code you just type: ; and then write whatever you want.
Ex:
Code:
While 1 ;;;start of loop
Wend ;;;end of loop
Now the code is commented , now I will go over to the loops.
The While is the beginning of the loop and the 1 is the expression.
The 1 means that the loop will continue until expression is false.
If you would put a 0 it will loop until the expression is true.
The Wend must always added if a While statement is declared.
Well that covers the loop, at least the basics of it
Now I will learn you how to make a hotkey and how to make the script/program click for you
Here is the code:
Code:
HotKeySet("{F4}", "ExitProg") ; ;;Sets F4 as a hotkey to exit the progam
HotKeySet("{F5}", "StartProg") ;;;Sets F5 as a hotkey to start the program
While 1
Sleep(100) ;;;Waits for function call
Wend
Func StartProg()
while 1
MouseClick("left") ;;;left clicks
Sleep(500)
WEnd
EndFunc
Func ExitProg()
Exit 0 ;;;Exits the program
EndFunc
Now I have putted some comments in the code so it's easier to understand.
The HotKeySet("{F4}", "ExitProg") means that we set F4 as a hotkey to the function ExitProg.
And the other sets it to start function.
Ok, as we don't want the script to just end instantly we need to make a loop which will wait for a function call.
Well, I don't need to take up the loop part again so I will explain what the sleep(100) does.
Some of you might know what it does, but I will explain it anyways, the sleep is like a pause period which you can set to whatever you want.
You set the time in milliseconds , which means 1000 = 1 sec.
Now the loop will continue until a function is called ( waits for you to press F3 or F4).
Now we will go to the functions which are quite simple .
A function always start with Func followed by the functions name, which is StartProg in this case.
Below that goes the code, which now is the mouse click.
We begin with the loop.. and then we put what it should do.
MouseClick("left") means that it will left click where the cursor is situated, you can change it to right if you want.
As you can see I have putted a little pause/delay between the clicks so it wont click too fast, in this case I took half a sec which is 500 in milliseconds.
Now we put the Wend and below that the EndFunc which means thats the end of that function.
Now we just have the ExitProg function left, which is very simple.
The Exit 0 simply just exit/terminate the program.
Hope you could understand the tutorial, as I'm not that great explaining things
Please comments
If you think it's use full give reputation please!
Last edited: