The FULL guide to making your own Bots/Macros...PART 2

12/20/2007 03:29 Hiyoal#1
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.

Quote:
Originally Posted by Hiyoal
MouseClick("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

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.

Quote:
Originally Posted by Hiyoal
MouseMove(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

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

Quote:
Originally Posted by Hiyoal
Global $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

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.

Quote:
Originally Posted by Hiyoal
MouseClickDrag("left", 0, 200, 600, 700, 5) ;Order: “Button”, “x” coord (#1), “y” coord (#1), “x” coord (#2), “y” coord (#2), “Speed”
• MouseDown and MouseUp

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

Quote:
Originally Posted by Hiyoal
MouseDown(“Left”)
Sleep(10000)
MouseUp(“Left”)
• MouseWheel

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 Hiyoal
MouseWheel(“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 [Only registered and activated users can see links. Click Here To Register...].
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>”

[Only registered and activated users can see links. Click Here To Register...]

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:
[Only registered and activated users can see links. Click Here To Register...]

Into THIS:
[Only registered and activated users can see links. Click Here To Register...]

• Making Transparent

To make transparent labels (only show text, doesn’t show grey background when on top of a picture), Generate Code [Only registered and activated users can see links. Click Here To Register...] 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”

Quote:
Originally Posted by Hiyoal
$Label1 = GUICtrlCreateLabel("Hello", 208, 40, 48, 28)
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)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
as so.

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.

[Only registered and activated users can see links. Click Here To Register...]

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:

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)
You can now see that if you press the button:
“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:

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

To fix this “Close” error use code like this:

Quote:
Originally Posted by Hiyoal
[COLOR=Red
$value=[/COLOR]InputBox("Test", "Press the X Button","","")
If @error=1 Then
Msgbox(0,"","Close")
Exit
EndIf
That is the end of my Part 2 guide to creating Bots/Macros yourself.

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 :cool:
12/20/2007 07:31 Real~Death#2
nice guide:)
im sure it took some time thanks man
+K
12/20/2007 14:53 Toopy#3
Nice Guide

I might use this guide for making some bots xD
+k
12/20/2007 19:37 DaSpy#4
Awesome work, it's organized and easy to understand. I can't wait till I get on my computer to test this new info.

+K for you
12/21/2007 05:09 ConquER_GuY_450#5
This doesn't make any sense, but how do you make green/red shadows?
12/21/2007 05:52 David5646#6
Good guide :D
12/21/2007 06:01 Hiyoal#7
@ConquER_GuY_450
Shadows for what???
And if you have read the First Guide to Making Bots and Macros then you would have understood this. It is all pretty basic and everyone except you has understood it -_-

Thanks to everyone else neway. Im glad you like it :P

Hiyoal :D
12/21/2007 06:48 -Truth-#8
thanks man XD
04/19/2008 21:54 IJazzI#9
Thank you for the guide. Its great not having to be a leech..:D

Very helpful.
04/19/2008 22:16 anerax#10
Good Guid !
Can you explain why can I modified memory adress and packet ?

Thx
04/19/2008 23:49 Hiyoal#11
I dont know packets, but I do know memory.

Ill make a new guide in the future explaining memory reading/writing and pixel search functions.

Hiyoal
04/20/2008 11:20 anerax#12
Thx, in fact, i would like when i "clic" on start, the memory adress value of xxxxxxxxx become 128 and the character speedhack...is it possble ?
04/21/2008 08:40 Hiyoal#13
Anything is possible. Look at UPSman's source code in autoit, it has this exact example you are looking for :p

Hiyoal
05/23/2008 22:18 kenners#14
great guide,
but i cant find one think: pixle serch, actuly i need script wich would detect two difrent pixles one next to one.
for exsample 0xFFFFF and next to it 0xFFFFC
i need that for some bot,

well if u know site/topic where i could get that/lern to make that or u can write it please help ><
05/24/2008 11:25 Hiyoal#15
Help file is always good to check. Or ask a question on the AutoIt forums.

Hiyoal :D