Part 1
Hi all,
As you have read in the thread title, this is a FULL guide for creating your own Bots and Macros. I will be teaching you some of the basic fundamentals in programming and also some advanced fundamentals which will include creating GUI's for your Bots and Macros. Advanced fundamentals will be in the 2nd Part of this tutorial.
Contents:
1. What we are using
2. Introduction to the AutoIt language
3. Declarations
4. Functions
5. If, Then, ElseIf and Else
6. Timers
7. Loops
8. Setting hotkeys
9. [Part 2]
1. What we are using
In this tutorial, I will be teaching you how to write code in
What is AutoIt??
is a multifunctional script writing tool which enables you to create simple to advanced programs. In part 1 of this tutorial I will be teaching you the very basics of script writing in . The script writer used for writing AutoIt code is called SciTE. This writer helps you write code more effectively and more efficiently while also giving the script an organised view.
2. Introduction to the AutoIt language
As I have explained above, AutoIt is a multifunctional script writing too which enables you to create simple to advanced programs. This means that script language should be understandable but at the same time, simple and easy to use. If you look at some Visual Basic coding examples, they can be understood but they contain lots of complicated coding in declarations and in the way in which one coding example may identify a process. AutoIt can use language to identify a process simply by using: ProcessExists().
See how AutoIt is much simpler?!
3. Declarations
Declarations an instruction or statement that defines data (fields, variables, arrays, etc.) and resources, but does not create executable code. This means that if I declare “ProcessExists(“[Conquer 2.0]”)” then I would write “$ANYTHINGHERE=ProcessExists(“[Conquer 2.0]”)”.
The use of $ or Dim in AutoIt will define data used in the program. I will explain this concept in more detail when we start writing some code.
4. Functions
Functions can be used to organise data and create different points for the program to read. If you create a Function which stores data about the function of pressing “F1” then you can set “Call” functions in other parts of your script to read and process the above function.
Eg.
5. If, Then, ElseIf and ElseQuote:
Originally Posted by HiyoalStart() ;Calls the Function named "Start"
Func Start()
$msgbox=Msgbox(4, “Start”, “4+1=6….Press yes if you think this equation is correct. Press no if you think it is incorrect”)
If $msgbox=6 then ;asks the program whether “Yes” was pressed. If it wasn’t then it skips this If statement
Incorrect() ;this calls the Function “Incorrect”
EndIf
If $msgbox=7then ;asks the program whether “No” was pressed
correct() ;this calls the Function “Correct”
EndIf
EndFunc
Func incorrect()
Msgbox(0, “Incorrect”, “You were incorrect”)
Exit
EndFunc
Func correct()
Msgbox(0, “Correct”, “You were correct”)
Exit
EndFunc
If, Then and Else commands are used in many scripting languages. What they do is ask the program a question. I have written some codes above which demonstrate how the If and Then statement work.
Eg. This Example will demonstrate If, Then and ElseIf and Else.
6. Timers and SendQuote:
Originally Posted by HiyoalIf $var >= 0 Then ;asks the program if $var is equal to more than 0, and if it is then it continues through code lines.
MsgBox(4096,"", "Value is positive.") ;displays a messagebox
ElseIf $var <= 0 Then ;if the above
MsgBox(4096,"", "Value is negative.")
Else
If StringIsXDigit ($var) Then
MsgBox(4096,"", "Value might be hexadecimal!")
Else
MsgBox(4096,"", "Value is either a string or is zero.")
EndIf
EndIf
Timers and Send Functions are one of the most important lines of code written for Bots and Macros. What a timer does is tell the program when to “stall” for a period of time. This can be used when using Sit functions in Conquer 2.0 when levelling a stamina skill. You will have to program your AutoIt script to “Sleep” for an amount of time to allow regeneration stamina time.
What the Send Function does is presses a button on your keyboard without you physically pressing it. This
Eg. This Example is a snippet of code from a personal Spiritual Healing Bot I have made.
For this coding to work, you would have to write values to the file hello.ini in @SystemDir\coolies\ for this line of code to work. Otherwise the program could not determine the value of $number and it would receive “”.Quote:
Originally Posted by HiyoalFunc StartHeal()
$number=IniRead(@systemdir & “\coolies\hello.ini”, “Hi”, “Sup”, “”) ;reads the value from an Ini file.
If $number=1 then
While $number=1
Sleep(12000) ;number is how many milliseconds to sleep for 12seconds
Send(“{F1}”) ;presses the F1 key
Wend
EndIf
If $number=2 then
Exit
EndIf
EndFunc
7. Loops
Loops are what they are. They cycle through code until the program tells them to stop or else the program quits. They can also cycle forever. This is very helpful when writing codes such as Auto Hunters because you might want the program to read certain user inputted data (SH “F” key. Eg. SH=F3) to cycle through steps until…say…the “Stop” hotkey is pressed.
Loops use the coding:
While
Wend
While tells the program when to start (If While is written using “While 1” then the program will loop forever until the program exits)
Eg. This example will loop through msg boxes until the declared statement $i adds up to 10 or above.
9. Setting HotkeysQuote:
Originally Posted by Hiyoal$i = 0 ; i is declared as equal to 0
While $i <= 10 ;While i’s value is below 10, Loop through below code
MsgBox(0, "Value of $i is:", $i) ;msg boxes the value of i
$i = $i + 1 ;rewrites i again but adds 1 to it so that i is equal to 1 more value to i then the last time.
WEnd
Hotkeys are used in Bots and Macros for the initiation of functions. They are usually used to start, pause, speed up, prompt or stop a program. They are very useful because they are easy to use and they are quick response. They are also easy to code .
Eg. This Example shows how to integrate hotkeys into a simple msgbox program.
8. Setting HotkeysQuote:
Originally Posted by Hiyoal
While 1
HotKeySet(“{INSERT}”,”Start”) ;Calls the function "Start" when INSERT is pressed
HotKeySet(“{END}”,”Exit”) ;Calls the function "Exit" when END is pressed
Wend
Func Start()
Msgbox(0, “Start”, “You have pressed the key INSERT and it has prompted this message!”)
EndFunc
Func Exit()
Msgbox(0, “Start”, “You have pressed the key END and it has prompted this message and will exit after you press OK”)
Exit
EndFunc
Hotkeys are used in Bots and Macros for the initiation of functions. They are usually used to start, pause, speed up, prompt or stop a program. They are very useful because they are easy to use and they are quick response. They are also easy to code .
Eg. This Example shows how to integrate hotkeys into a simple msgbox program.
9. Part 2Quote:
Originally Posted by Hiyoal
While 1
HotKeySet(“{INSERT}”,”Start”) ;Calls the Function "Start"
HotKeySet(“{END}”,”Exit”) ;Calls the Function "Exit"
Wend
Func Start()
Msgbox(0, “Start”, “You have pressed the key INSERT and it has prompted this message!”)
EndFunc
Func Exit()
Msgbox(0, “Start”, “You have pressed the key END and it has prompted this message and will exit after you press OK”)
Exit
EndFunc
I hope that everyone can benefit from this Guide on creating Bots and Macros for themselves and for the community.
Written by Hiyoal
For Elitepvpers
Hiyoal