Part 2
Hi all,
This is the second guide to making your own Bots and Macros using the script writer AutoIt. I have explained basic fundamentals in my previous Basic Guide on how to create Bots and Macros for Conquer and I will be further sharing my knowledge on how to create bots using Mouse Clicks and GUI for your programs.
Contents:
1. AutoIt Window Info
2. Mouse Functions
• MouseClick
• MouseMove
• MouseGetPos
• MouseClickDrag
• MouseDown and MouseUp
• MouseWheel
3. What are GUI’s?
4. Creating a GUI
• Making Transparent
5. Incorporating past knowledge into GUI
6. Debugging Code
1. AutoIt Window Info
In this tutorial I will be using AutoIt Window Info for both Mouse Functions and GUI. AutoIt Window Info can be found in your AutoIt folder. Eg. “C:\Program Files\AutoIt3\Au3info.exe”. This program enables you to get information about a program which you can use for GUI and mouse such as finding what coordinates your mouse is at.
2. Mouse Functions
Conquer 2.0 is a clicking game. You don’t use the arrow keys at all, so for making Bots and Macros for Conquer 2.0 you need to incorporate the mouse. AutoIt scripting supports mouse functions in all the ways you will ever need it to.
• MouseClick
MouseClick is a function which tells the cursor in Windows to click. You can specify which button you want clicked, where you want it clicked and how many clicks you want the macro to send to the mouse.
Eg. This is an example of the MouseClick Function.
• MouseMoveQuote:
Originally Posted by HiyoalMouseClick("Left",76, 749,1) ;Order of operations are "MouseClick" function, "Mousebutton" being used, "x" and "y" pixel axis of screen, "clicks" the number of clicks
Sleep(2000) ;stalls program for 2 seconds
MouseClick("Left",981, 757,2) ;clicks on your Time bar
MouseMove is a function which tells the cursor in windows to change its position (measured in pixels). You can specify where to move the mouse and how fast it should change its position (Range: 0 “Fastest”, 100 “Slowest”)
Eg. This is an example of the MouseMove Function.
• MouseGetPosQuote:
Originally Posted by HiyoalMouseMove(10,10,0) ;moves mouse to points 10,10 (pixels) in an instant
Sleep(5000) ;stalls for 5 seconds
MouseMove(100,57,50) ;moves mouse to points 100,57 (pixels) slower than first mousemove
MouseGetPos is a function which tells the program where your mouse is (x and y values of coordinates). This can be used to make an autoclicker for Conquer but to specify where the mouse is for the MouseClick function, you need to make a declaration before so that the program can read where the mouse is and store it, not just find where the mouse is and never use it.
Eg. This is an example of an autoclicker
• MouseClickDragQuote:
Originally Posted by HiyoalGlobal $counter=0 ;globally declare $counter to the program, not just as a variable contained in a Function
While 1
HotKeySet("{INSERT}","Start")
HotKeySet("{END}","END")
WEnd
Func Start()
$counter=1
While $counter=1
$getpos=MouseGetPos() ;finds where the mouse is at (in x and y coordinates)
MouseClick("Left",$getpos[0],$getpos[1],1) ;$getpos[0] is the x coordinate number from MouseGetPos and $getpos[1] is the y coordinate number from MouseGetPos
WEnd
EndFunc
Func End()
$counter=0
EndFunc
MouseClickDrag is a function which tells the mouse to click at a coordinate and hold down the mouse button and move to another coordinate. This can be used to make an Autotrader in Conquer or an Autodropper.
Eg. Here is an example of the mouseclickdrag function.
• MouseDown and MouseUpQuote:
Originally Posted by HiyoalMouseClickDrag("left", 0, 200, 600, 700, 5) ;Order: “Button”, “x” coord (#1), “y” coord (#1), “x” coord (#2), “y” coord (#2), “Speed”
MouseDown is a function which tells the mouse to hold down the mousebutton until the MouseUp function is called.
Eg. This is how you can incorporate MouseDown and MouseUp Functions in AutoIt
• MouseWheelQuote:
Originally Posted by HiyoalMouseDown(“Left”)
Sleep(10000)
MouseUp(“Left”)
MouseWheel is a function which tells the cursor or mouse functions for 2000/NT/XP to move the mousewheel in a direction for a certain amount of repetitions. This could be used in conquer to make an auto tao bot which casts spells and regens magic by sitting in the “Little rock” at PC Caves.
Eg.
__________________________________________________ __________________________________________________ _________________________Quote:
Originally Posted by HiyoalMouseWheel(“Down”,10) ;moves the mousewheel down 10 times (in clicks)
MouseWheel(“Up”,10) ;moves the mousewheel up 10 times (in clicks)
3. What are GUI’s?
GUI stands for Graphical User Interface. This is User friendly and it is better to use a GUI instead of giving prompts such as MsgBoxes. You can also make it look nice and it gives the User an image to refer to instead of just pressing buttons and not knowing what they are doing.
4. Creating a GUI
GUI is Extremely Hard to create when writing code. It is much better if you can use your mouse to click and drag, resize and customise the look without debugging code continually. So… I have found a program on the internet called .
It is a visual GUI creator which makes creating GUI for AutoIt much faster then writing code.
If you are going to code GUI then always start off the coding with “#include <GUIConstants.au3>”
KODA is pretty straight forward to use but I have realised that it does not include Transparency for Labels in the Styles or ExStyles tabs. I have also figured out how to make transparent labels from making
THIS:
Into THIS:
• Making Transparent
To make transparent labels (only show text, doesn’t show grey background when on top of a picture), Generate Code from a GUI script with a background and a label in it, and copy and paste into an *.au3 file.
Next, open the script ([Edit script], not [Run script]) and find the words “GUICtrlCreateLabel”
Now enter down a line from the end of $label1 and write “GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)Quote:
Originally Posted by Hiyoal$Label1 = GUICtrlCreateLabel("Hello", 208, 40, 48, 28)
as so.Quote:
Originally Posted by Hiyoal$Label1 = GUICtrlCreateLabel("Hello", 208, 40, 48, 28)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
Now you have Transparent Labels!!!
5. Incorporating past knowledge into GUI
From what we have learnt so far in creating and writing code in AutoIt, I can now explain how to make a GUI which…FUNCTIONS. If you just create a GUI with buttons and other fancy things but do not include any written code from the Part 1 Guide, Mouse Functions or File Read Functions then the program will do NOTHING.
Here is a template in which I have explained how to incorporate past knowledge into GUI. Open this up using SciTE editor and read the green lines if you do not understand how something works.
6. Debugging Code
If you ever want to know a value of a returned $variable then use MsgBoxes. I use these all the time to see whether a function has failed or succeeded in running through the code. You can check what some different values will return in AutoIt if you read the Help File. This is how I have learnt all the things I have been teaching you.
An example of debugging is:
You can now see that if you press the button:Quote:
Originally Posted by Hiyoal
$value=Msgbox(3, “Test”, “Click on the buttons below and I can you can see what each returns”)
Msgbox(0, “”, $value)
“Yes”:: it will receive the value “6”
“No”:: it will receive the value “7”
“Cancel”:: it will receive the value “2”
You can now write code like this:
One last thing I have not pointed out with AutoIt scripting is that when you use the instance “InputBox”, you cannot just close it when it are in use (You can click the X button, but the Box will not close). I have not explained InputBoxes but by reading the prompts when in SciTE, you will be able to determine how they work.Quote:
Originally Posted by Hiyoal
$value=Msgbox(3, “Test”, “Click on the buttons below and I can you can see what each returns”)
If $value=6 Then
Msgbox(0, “”, “You pressed Yes”)
Exit
ElseIf $value=7 Then
Msgbox(0, “”, “You pressed No”)
Exit
ElseIf $value=2 Then
Msgbox(0, “”, “You pressed Cancel”)
EndIf
To fix this “Close” error use code like this:
That is the end of my Part 2 guide to creating Bots/Macros yourself.Quote:
Originally Posted by Hiyoal
[COLOR=Red$value=[/COLOR]InputBox("Test", "Press the X Button","","")
If @error=1 Then
Msgbox(0,"","Close")
Exit
EndIf
I hope you have all found this very helpful because it has taken me a long time to write and edit this.
Written by Hiyoal
For ElitePvPers
Hiyoal