Not a member yet? Register for your free account!


Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 09:33

  • Please register to post and access all features, it's quick, easy and FREE!

 

[TUTORIAL] How to make a BOT

This is a discussion on [TUTORIAL] How to make a BOT within the AutoIt forum part of the Coders Den category; CHAPTER 1 GUI (Graphical User Interface) Introduction This is just the basics of AutoIt. By the end of this tutorial ...

Reply
 
Thread Tools
Old 12-21-2009, 04:18   #1
Member
 
Join Date: Oct 2009
Posts: 63
Received Thanks: 553
[TUTORIAL] How to make a BOT



CHAPTER 1

GUI (Graphical User Interface)

Introduction
This is just the basics of AutoIt. By the end of this tutorial you will be able to create your own little simple bot that can spam custom timed key strokes.

To download AutoIt just visit their website at and download the latest version (version 3.3.0.0 as of today). Download, run it, install it... you know what to do.
Section 1
Create a new folder
Create a new folder and call it "Scripts".

Create a .au3 file
Alright, now that you have AutoIt installed you should be able to create a new .au3(autoit script) file. Simply right click any where in the folder, then hit the new button, and then click AutoIt v3 Script.

Name the file
Now name the file what ever you want, for example I named my "epoxgonewild".

Open the file
Open the autoit v3 script file, right click and press Edit.
Section 2
Adding proper header
Now that you have the .au3 file open lets begin to write shit in it. Before we do anything you should always add the proper header to your code. I usually use something pretty/fancy looking like this.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
CS stands for comment start and indicates the beginning of a comment. You don't necessarily have to have all those dashes after it, just makes it look nice.
CE if you haven't figured it out by now(shame on you), stands for comment end and is the last line of the comment (you can have text after it but only on that line).

Importing the GUI features
If you want to use GUI (graphical user interface) you must add this line so autoit recognizes and can import the GUI features you use.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUISetState(@SW_SHOW)
The GUISetState statement basically tells the program once run that it should show the GUI, without adding this the program will not display GUI. Be sure to always have this piece the last part of your GUI section because the program is read from top to bottom once run.

Making the frame
Pew pew, first cool step. In AutoIt all you have to do is add GUICreate and define the window title and dimensions. Easy enough, right?
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)

GUISetState(@SW_SHOW)
("Forsaken's Bot", 335, 100)
("x", y, z)

x = The windows title, it will appear in the window bar where you close and minimize the program.
y = The windows width, determines how wide/horizontal the program is.
z = The windows height, determines how high/vertical the program is.

If all was done correctly, once run your frame should look like this.

###NOTE: If you went on ahead and saved/ran the program it should have opened just for a second and then closed. That is fine, we will fix that later once we add some actual code.###

Add the code below to end of the script if you do want to preview it.
Code:
While 1
	sleep(1)
WEnd
Section 3
Adding a label
Label, other wise known as text. For that we use GUICtrlCreateLabel.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)

GUICtrlCreateLabel("text", 8, 10)

GUISetState(@SW_SHOW)
("text", 8, 10)
("x", y, z)

x = What ever is put inside of the quotation marks will be printed in the frame you made.
y = This is the horizontal position of where the text will be placed, I am not sure but I believe it is measure in pixels.
z = This is the vertical position of where the text will be placed.

You should have something that looks like this now.

###NOTE: If you went on ahead and saved/ran the program it should have opened just for a second and then closed. That is fine, we will fix that later once we add some actual code.###

Add the code below to end of the script if you do want to preview it.
Code:
While 1
	sleep(1)
WEnd


Adding Input box
Input are used to submit data (such as text, numbers, and symbols) from the user and store them. Using GUICtrlCreateLabel.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)

GUICtrlCreateLabel("text", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)

GUISetState(@SW_SHOW)
$key1 This is a variable/string. This stores what ever comes after it, which in this case would be what ever the user inputs into the input box we made. It allows you to reference back to it and use it. You can name this what ever you want (ex. $input $lol $epoxisgay $wtfsfsdf)

("", 35, 8, 120)
("x", y, z, s)

x= Leave this blank, unless you want default text there. It can be edited by user.
y = Horizontal position.
z = Vertical position.
s = Width of the input box.

If all is done correctly, it should look like this now.

###NOTE: If you went on ahead and saved/ran the program it should have opened just for a second and then closed. That is fine, we will fix that later once we add some actual code.###

Add the code below to end of the script if you do want to preview it.
Code:
While 1
	sleep(1)
WEnd
Section 4
Duplicating code
Since this a very long tutorial already (we are only half way) I am just going to skip explaining step by step how to add more labels and input boxes because it's exactly the same method listed in section 3. All you have to do is change the positions and variable/string names.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)

GUICtrlCreateLabel("Text", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Text", 8, 44)
$time1 = GUICtrlCreateInput("", 35, 40, 120)

GUISetState(@SW_SHOW)
I just added 1 more label and more input with the variable/string $time1.

Re-labeling
Okay, so this is almost the end of the GUI portion we just need to add start button. But first lets rename those labels to something that the user will understand.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)


GUICtrlCreateLabel("Key", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Time", 8, 44)
$time1 = GUICtrlCreateInput("", 35, 40, 120)

GUISetState(@SW_SHOW)

###NOTE: If you went on ahead and saved/ran the program it should have opened just for a second and then closed. That is fine, we will fix that later once we add some actual code.###

Add the code below to end of the script if you do want to preview it.
Code:
While 1
	sleep(1)
WEnd
Section 5
Adding a button
The button is what will start the botting. We will be using the GUICtrlCreateButton function to create the button.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)

GUICtrlCreateLabel("Key", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Time", 8, 44)
$time1 = GUICtrlCreateInput("", 35, 40, 120)

$startbutton = GUICtrlCreateButton("Start", 190, 8, 60)

GUISetState(@SW_SHOW)
$startbutton is the variable we assigned to the button so we can refrence back to it once we need it.

("Start", 190, 8, 60)
("x", y, z, s)

x= Button label.
y = Horizontal position.
z = Vertical position.
s = Width of the button.


###NOTE: If you went on ahead and saved/ran the program it should have opened just for a second and then closed. That is fine, we will fix that later once we add some actual code.###

Add the code below to end of the script if you do want to preview it.
Code:
While 1
	sleep(1)
WEnd


__________________

TheForsaken is offline  
Thanks
167 Users
'Merica (11-20-2011), *-Elsword_Hacker-* (12-13-2012), -Zombie-001- (11-07-2011), .-FreeZer-. (02-25-2012), .Cdog (06-12-2011), .Nguyen (10-08-2010), 0Player (04-07-2014), ABD058 (01-17-2014), Achat (04-12-2012), adoaje (08-11-2012), Ahzsyjie (09-18-2010), Algaten™ (07-19-2010), allesweg... (08-07-2010), altehupe (01-27-2010), Andr3rb5 (08-05-2014), andreyo2011 (08-19-2012), andygomez101 (03-13-2010), aragonik (01-22-2010), Artarex (07-30-2010), asahi123 (05-13-2011), Bansei2 (12-26-2010), batitun (09-21-2010), bboyecko (03-18-2010), blademihai27 (01-10-2010), bogdan06 (10-07-2011), Bogenkiller (05-15-2010), Bone-marrow (06-27-2013), Brand95 (11-11-2012), Breaking'Thunder (02-04-2012), Burkey (01-20-2014), Cash² (05-01-2010), chilz111 (01-26-2010), Combat (11-21-2011), cosmin890 (02-09-2010), crackingz (04-18-2013), crashiiik (12-07-2012), crazydisser (05-27-2011), Dacyon (09-29-2010), Daddy Neuland (11-02-2010), dakrmancz (03-03-2014), DarkMission (12-04-2010), Dein Verstand (11-21-2012), derrod (10-07-2012), DevilMayCry3 (12-25-2009), DjXr3aLmZ (05-02-2010), dommerle (07-25-2011), dondale8 (05-22-2010), Dorhaxxx (10-11-2011), Dosiiii (09-23-2012), dr3amw4lker (05-25-2010), Duwong! (01-04-2010), egzonii (10-01-2011), elloco@1 (04-14-2013), Endorfin (02-06-2012), eugnm (10-26-2012), ExerlosMyst (11-15-2012), f3nd3 (03-30-2011), Fa111l (09-22-2010), fatihkurt11 (05-21-2013), Forfirith (10-01-2010), foxhound83 (09-20-2013), FreundBlase (08-02-2010), gamer96 (02-20-2012), genesisVI (06-15-2012), Ghost dragon (02-25-2012), GhostSnipezz (10-30-2011), Hackerfreak1 (11-24-2010), Hav0k66 (04-18-2010), HeavyMetalToast (02-18-2013), hiflyer (04-08-2014), hoocrax (07-03-2011), Hosenmist95 (11-11-2013), Hupfi10 (10-07-2012), ichdudu (01-05-2013), iJonas (12-06-2010), Infylos (08-31-2012), Joey. (07-21-2010), JohnHeatz (09-15-2012), Joystick121 (04-21-2014), kamikze55 (09-02-2010), khiladi_726 (09-22-2013), Kreisler (07-02-2011), Kurosaki' (08-23-2011), l3obn4tzer (11-05-2011), LastS0ul (07-26-2013), legendgb1 (07-22-2013), Linoskoczek (08-20-2012), lordcis23 (07-23-2012), loretde (02-28-2010), LostHope. (08-14-2011), lukkigi (03-28-2010), Maffiagang (02-01-2013), makradesh (02-18-2011), marcelkd (11-27-2013), mare90 (03-11-2010), micron (09-24-2011), MIROELHACKER (05-04-2013), MisterBingo (05-05-2012), mongogb (05-04-2011), mono0 (10-11-2010), mooface (10-24-2010), mrapc (02-26-2011), MuPowe (06-26-2013), najky123 (06-22-2012), namanem (01-27-2011), Namikazze (04-03-2012), Nelunia (01-08-2011), NeonBurn (05-11-2013), nexo1977 (06-17-2011), nixgibts (09-22-2011), Noname997 (11-03-2011), noobinator92 (08-08-2010), NukePROOF (02-15-2010), nwomatt (12-19-2010), Omdihar (07-21-2010), ouka (04-24-2011), ozany (01-16-2011), Pen123456 (03-30-2013), Pexus (06-20-2010), Primmo (04-13-2013), Professor Linebeck (11-17-2010), pulha123 (01-26-2010), reversegamer90 (11-10-2012), RF1T3 (10-28-2012), Sarpa1053 (09-30-2010), sasukegamer (02-18-2012), sbob10 (02-16-2011), sefa1974 (08-02-2010), shiro225 (01-24-2013), shooteram (08-11-2012), Siktor (12-21-2013), Sir Ryuuzaki (04-17-2010), Skyrok (06-28-2011), Slicktor (02-21-2012), sloktok (08-28-2010), Sonyacc (05-11-2012), SpikeMonster (02-03-2013), STdata (01-11-2012), STIVKOOMAN (07-08-2013), Sukaru1 (12-20-2011), Superman44 (03-21-2010), sweeed01 (08-02-2010), Teddy' (10-14-2012), thx4nothing (07-23-2011), tox124 (11-21-2013), Trixxter921 (06-17-2014), TrolligerTroll (11-04-2013), Ummayr (09-10-2013), Unredlich (06-11-2013), VitaminD (03-17-2010), wagnolf (08-13-2010), Wellingtonmaru (07-18-2012), wr verkäufer (04-05-2010), wurzes (03-02-2012), xBlizzarD (02-19-2013), xclusive™ (06-10-2011), xDarkMan (06-24-2013), xohoo (11-30-2010), xXDarkHellXx (08-15-2010), Yarobe (04-21-2013), zawcawbaw2 (08-31-2013), zCrossYuuki (07-12-2012), zilwas (06-28-2011), ZzEndayZz (09-21-2013), _Habi_ (04-10-2011), _SanDmaN_ (10-18-2010), •Giant•Epic•Smiley• (10-03-2010)
Old 12-21-2009, 04:18   #2
Member
 
Join Date: Oct 2009
Posts: 63
Received Thanks: 553

CHAPTER 2

The Inner Coding (what makes it tick)

Introduction
Alright so now that we added the GUI, lets begin adding the actual coding.
Section 1
Adding a while loop
A while loops is controled flow statement that allows code to be executed repeatedly based on a given condition.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)

GUICtrlCreateLabel("Key", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Time", 8, 44)
$time1 = GUICtrlCreateInput("", 35, 40, 120)

$startbutton = GUICtrlCreateButton("Start", 190, 8, 60)

GUISetState(@SW_SHOW)

While 1
	$msg = GUIGetMsg()
	
WEnd
While 1 indicates the begining of a while loop and WEnd stands for While End which signifies that the end of the while loop statement. If you run your code now the gui will not close nor can you close it yet using the exit button.

The GUIGetMsg used in $msg = GUIGetMsg() polls the GUI to see if any events have occurred. And will be used later on in the code.

Adding a Case statement
Now we will add a case or otherwise known as select statement inside of our while loop. The select statement gives the user the ability to decide what the program does next based on what the user clicks or does.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)

GUISetState(@SW_SHOW)

GUICtrlCreateLabel("Key", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Time", 8, 44)
$time1 = GUICtrlCreateInput("", 35, 40, 120)

$startbutton = GUICtrlCreateButton("Start", 190, 8, 60)

While 1
	$msg = GUIGetMsg()
	
	Select
		
		Case $msg = $startbutton
			
		Case $msg = $GUI_EVENT_CLOSE
			
	EndSelect
		
WEnd
What we have done is added a Select statement with two options
Option 1: $msg = $startbutton, that means if the startbutton is pressed it will trigger what ever code is inside this case statement. ( we havent added the code inside yet)

Option 2: $msg = $GUI_EVENT_CLOSE, which means that if the exit button (the x button) is pressed it will trigger what ever code comes inside this case statement. ( we haven't added the code inside yet)
Startbutton event
Now lets tell the program what to do once the start button is pressed.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)

GUISetState(@SW_SHOW)

GUICtrlCreateLabel("Key", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Time", 8, 44)
$time1 = GUICtrlCreateInput("", 35, 40, 120)

$startbutton = GUICtrlCreateButton("Start", 190, 8, 60)

While 1
	$msg = GUIGetMsg()
	
	Select
		
		Case $msg = $startbutton
				$send1 = GUICtrlRead($key1)
				$sleep1 = GUICtrlRead($time1)
			
		Case $msg = $GUI_EVENT_CLOSE
			
	EndSelect
		
WEnd
First it will declare all variables. This means it will read what the user input into our two input field $time1 and $key1, and make it usable in the code to follow.

$key1 is assigned the new variable $send1. When ever we refer to $send1 now will be what ever the user input into the $key1 input.

$time1 is assigned the new variable $sleep1. When ever we refer to $sleep1 now will be what ever the user input into the $time1 input.

Next we will add another while loop because we want to spam this part until the user says STOP.
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)

GUISetState(@SW_SHOW)

GUICtrlCreateLabel("Key", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Time", 8, 44)
$time1 = GUICtrlCreateInput("", 35, 40, 120)

$startbutton = GUICtrlCreateButton("Start", 190, 8, 60)

While 1
	$msg = GUIGetMsg()
	
	Select
		
		Case $msg = $startbutton
				$send1 = GUICtrlRead($key1)
				$sleep1 = GUICtrlRead($time1)
			While 1	
				Send($send1)
				Sleep($sleep1)
			WEnd
			
		Case $msg = $GUI_EVENT_CLOSE

	EndSelect
		
WEnd
We just added another while loop like you did before but we also added something new inside of it this time.

Send is the command that tell the computer to literally send a key stroke. You can do something like Send("hello") and the program will send out the word hello in any window.

Sleep is basically a pause. It pauses the program for the specified amount of time. Example, Sleep("10000") will pause the program from going on to the next line of code for 10 seconds (10x1000, milliseconds)

But in our case we substituted the "hello" and "10000" with variables that the user has defined. Buy putting in $sleep1 and $send1 instead, the program will automatically put in what ever the user put in the input boxes we created chapter 1. This gives the user the choice to easily choose which key is being sent and how long the pause will be with out editing the actual source code.

Exit button event
The $GUI_EVENT_CLOSE function will exit the loop and destroy the GUI, or exit/close the program
Code:
#cs ----------------------------------------------------------------------------
	AutoIt Version: 3.3.0.0
	Author: Forsaken 
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>

GUICreate("Forsaken's Bot", 335, 100)

GUISetState(@SW_SHOW)

GUICtrlCreateLabel("Key", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Time", 8, 44)
$time1 = GUICtrlCreateInput("", 35, 40, 120)

$startbutton = GUICtrlCreateButton("Start", 190, 8, 60)

While 1
	$msg = GUIGetMsg()
	
	Select
		
		Case $msg = $startbutton
				
				$send1 = GUICtrlRead($key1)
				$sleep1 = GUICtrlRead($time1)
				
			While 1	
				Send($send1)
				Sleep($sleep1)
			WEnd
			
		Case $msg = $GUI_EVENT_CLOSE
			GUIDelete()
			ExitLoop
			
	EndSelect
		
WEnd
GUIDelete() deletes the GUI we created and reomves it from the screen.

ExitLoop does exactly what it says it does, it exits the loop (while 1) statement above that spams the keys.

The End
And tha... tha... tha, that, that's all folks. You can now run your program and it will spam your custom key in your custom time.


TheForsaken is offline  
Thanks
112 Users
'Merica (11-20-2011), .Cdog (06-12-2011), .Nguyen (10-08-2010), 0Player (04-07-2014), ABD058 (01-17-2014), Achat (04-12-2012), adoaje (08-11-2012), Ahzsyjie (09-18-2010), allesweg... (08-07-2010), Andr3rb5 (08-05-2014), andreyo2011 (08-19-2012), aragonik (01-22-2010), Artarex (07-30-2010), asahi123 (05-13-2011), ax5 (01-21-2010), Bansei2 (12-26-2010), batitun (09-21-2010), blademihai27 (01-10-2010), Bogenkiller (05-15-2010), Bone-marrow (06-27-2013), Brand95 (11-11-2012), Cheatengine1 (09-11-2011), chilz111 (01-26-2010), Combat (11-21-2011), corectsunt (04-02-2013), CyberPriest (08-16-2010), Daddy Neuland (11-02-2010), dakrmancz (03-03-2014), DaNoobfb (09-25-2012), DarkMission (12-04-2010), dego4ever (03-08-2012), Dein Verstand (11-21-2012), derrod (10-07-2012), DjXr3aLmZ (05-02-2010), dondale8 (05-22-2010), Dosiiii (09-23-2012), dr3amw4lker (05-25-2010), egzonii (10-01-2011), eugnm (10-26-2012), Fa111l (09-22-2010), Forfirith (10-01-2010), foxhound83 (09-20-2013), gamer96 (02-20-2012), Hav0k66 (04-18-2010), Hosenmist95 (11-11-2013), Hupfi10 (10-07-2012), ichdudu (01-05-2013), JohnHeatz (09-15-2012), khiladi_726 (09-22-2013), Kurosaki' (08-23-2011), l3obn4tzer (11-05-2011), legendgb1 (07-23-2013), Linoskoczek (08-20-2012), LOLAHAHS (02-04-2010), lordcis23 (07-23-2012), loretde (02-28-2010), LostHope. (08-14-2011), Maaax (05-10-2010), makradesh (02-18-2011), marcelkd (11-27-2013), mare90 (03-11-2010), micron (09-24-2011), MisterBingo (05-05-2012), mlukac89 (11-04-2012), mongogb (05-04-2011), mono0 (10-11-2010), mooface (10-24-2010), mrapc (02-06-2011), MuPowe (06-26-2013), namanem (01-27-2011), Nelunia (01-08-2011), NeverMeltIce. (10-13-2013), nexo1977 (06-17-2011), nixgibts (09-22-2011), ni_ccc (02-18-2011), nwomatt (12-19-2010), OldLucieN (05-23-2010), ouka (04-24-2011), Pexus (06-20-2010), Plan3t (10-21-2010), punk14andu (05-27-2010), Requiable (11-19-2012), reversegamer90 (11-10-2012), RF1T3 (10-28-2012), Sarpa1053 (09-30-2010), sasukegamer (02-18-2012), sbob10 (02-16-2011), sempoiboyzer (11-03-2013), shooteram (08-11-2012), Sir Ryuuzaki (04-17-2010), Skyrok (06-28-2011), sloktok (08-28-2010), Sonyacc (05-11-2012), STdata (01-11-2012), Sukaru1 (12-20-2011), sweeed01 (08-02-2010), thx4nothing (07-23-2011), tihawk (05-16-2010), tomatomato (04-04-2010), tox124 (11-21-2013), Trixxter921 (06-17-2014), TrolligerTroll (11-04-2013), Unredlich (06-11-2013), wagnolf (08-13-2010), Wellingtonmaru (07-18-2012), wr verkäufer (04-05-2010), wurzes (03-02-2012), xXDarkHellXx (08-15-2010), zilwas (06-28-2011), _Handicap03_ (05-31-2010), •Giant•Epic•Smiley• (10-03-2010), »Côoper«™ (06-16-2011)
Old 12-21-2009, 04:18   #3
Member
 
Join Date: Oct 2009
Posts: 63
Received Thanks: 553

CHAPTER 3

Additional Features (some other cool shit)

Introduction
Okay so here we are part 3. Congratulations to the few who actually took the time read this. This section will teach you other useful tricks that can be used for gaming. This section will be updated constantly, so always check back to see new updates. Please press the Thanks button to keep the updates coming.
TimerInit and TimerDiff
The downfall to using Sleep(time) is that it pauses the entire code. Once in Sleep you can't do anything except wait. The alternative is to use the TimerInit() and TimerDiff() functions. With this you can continue on with your code while waiting for another chunk of code. We can do this by using these two functions in an if statement. Okay, so here is the code...
Code:
$timer = TimerInit()

While 1
	$timed = TimerDiff($timer)
	If $timed > 3000 Then ; we use greater than (>) because sometimes it might get skipped
		MsgBox(1,"TimerDiff","TimerDiff : "&$timed)
		$timer = TimerInit()
	EndIf
WEnd
The first TimerInit() is placed outside loop or if statement. The code is executed in order from top to bottom. Once it reaches the line $timer = TimerInit() it will begin the timer then move on to the next line. Then next line would be our loop where it is constantly checking if $timed is greater then 3000 (3 seconds). The timerDiff returns the difference in time from a previous call to TimerInit(). If timerDiff is greater then 3000 then the code will be executed, which in this case is just a message box. Now after the message box we added another $timer = TimerInit() because the first $timer = TimerInit() is still counting up and it doesn't count down so $timed will never equal 3000 again. Adding another $timer resets the count so the if statement has a chance to pick it up again.

ControlSend
Send, sends key(s) to any window on top and this can get very sloppy at times. Using ControlSend we can send key(s) to specific window. This doesn't require the window to be active, on top, or even maximized. It will work as long as the window is opened.
Code:
ControlSend ( "title", "text", controlID, "string" [, flag] )
Example
Code:
ControlSend("Untitled - Notepad", "", "", "Hello world!")
Sleep("100")
ControlSend("Untitled - Notepad", "", "", "{ENTER}"
Sleep("100")
ControlSend("Untitled - Notepad", "", "", "This is the line after the ENTER key was pressed.")
This one is pretty simple and the code explains its self. You have to enter the exact window name for this to work. The rest explains itself.

Changing button text
Using GUICtrlSetData we can change anything on the GUI right there on the spot. All we have to do is add a Switch and If statement and we can get a working Start/Stop button.
Code:
#include <GUIConstantsEx.au3>

GUICreate("GUICtrlSetData", 200,100)
GUISetState(@SW_SHOW)

$button = GUICtrlCreateButton("Start",60, 30, 80, 20)
$count = 0

While 1
	Switch GUIGetMsg()
	Case $button
		If $count = 1 Then
			GUICtrlSetData($button, "Start")
			$count = 0
		ElseIf $count = 0 Then
			GUICtrlSetData($button, "Stop")
			$count = 1
		EndIf
	Case $GUI_EVENT_CLOSE
		Exit
	EndSwitch
WEnd
GUICtrlSetData($button, "Stop")

So $button would be what ever we are changing. In this case the variable $button is assigned to a button that contains the data "Start". The second part of the function is what we are changing the data to, which we will be changing it to "Stop".
TheForsaken is offline  
Thanks
91 Users
'Merica (11-20-2011), 0Player (04-07-2014), Achat (04-12-2012), adoaje (08-11-2012), adri1205 (05-06-2014), Ahzsyjie (09-18-2010), allesweg... (08-07-2010), andreyo2011 (08-19-2012), aragonik (01-22-2010), Artarex (07-30-2010), ax5 (01-21-2010), blademihai27 (01-10-2010), Bogenkiller (05-15-2010), Bone-marrow (06-27-2013), Brand95 (11-11-2012), Cheatengine1 (09-11-2011), chilz111 (02-20-2010), chrisrey143 (10-19-2010), Cookedtoast (12-03-2010), Cool841 (07-26-2014), corectsunt (04-02-2013), crosslufael (04-29-2012), Daddy Neuland (11-02-2010), dakrmancz (03-03-2014), DarkMission (12-04-2010), derrod (10-07-2012), dondale8 (05-22-2010), dopeman1 (02-14-2012), dr3amw4lker (05-25-2010), eugnm (10-26-2012), Fa111l (09-22-2010), Forfirith (10-01-2010), foxhound83 (09-20-2013), gamer96 (02-20-2012), genesisVI (06-19-2012), Hupfi10 (10-07-2012), hyago121 (11-14-2012), ichdudu (01-05-2013), jazzdwayouwar (07-24-2012), JohnHeatz (09-15-2012), khiladi_726 (09-22-2013), l3obn4tzer (11-05-2011), LastS0ul (07-26-2013), Linoskoczek (08-20-2012), lordcis23 (07-23-2012), loretde (02-28-2010), LostHope. (08-14-2011), makradesh (02-18-2011), marcelkd (11-27-2013), mare90 (03-11-2010), mdzulahzier (01-20-2014), micron (09-24-2011), mongogb (05-04-2011), mono0 (10-11-2010), mooface (10-24-2010), mrapc (02-26-2011), namanem (01-27-2011), Nelunia (01-08-2011), nexo1977 (06-17-2011), nwomatt (12-19-2010), Plan3t (10-21-2010), Primmo (04-13-2013), punk14andu (05-27-2010), qqter (02-27-2010), raymeboy (02-02-2010), reversegamer90 (11-10-2012), RF1T3 (10-28-2012), Sarpa1053 (09-30-2010), sasukegamer (02-18-2012), sbob10 (02-16-2011), sefa1974 (08-03-2010), Shimoli (02-26-2014), sido47 (02-13-2011), Sir Ryuuzaki (04-17-2010), Skyrok (06-28-2011), sloktok (08-28-2010), STdata (01-11-2012), sweeed01 (08-02-2010), tihawk (05-16-2010), tox124 (11-21-2013), Trixxter921 (06-17-2014), udoL (07-30-2010), Ummayr (09-10-2013), Unredlich (06-11-2013), Wellingtonmaru (07-18-2012), wr verkäufer (04-05-2010), WTF!! (10-12-2010), wurzes (03-02-2012), [SGA]Potti (04-05-2010), •Giant•Epic•Smiley• (10-03-2010), »Côoper«™ (06-16-2011)
Old 12-21-2009, 04:20   #4
Member
 
Join Date: Oct 2009
Posts: 63
Received Thanks: 553

CHAPTER 4

Pixel Search (auto pot)

Introduction
In this part of the tutorial you will learn how to create a BOT that automatically uses HP/MP potions.
The HP/MP bar
Before we do anything we have to know how this will work and you need to get familiarized with the HP/MP bar we will be using as an example in this tutorial.

First lets take a look at this HP/MP bar below.


There is the color red and blue bars are full indicating that the character has maximum HP (health) and MP (manna).

Now look at this HP/MP bar.


From this HP/MP bar we can tell that the user has taken damage and no longer has full HP. There is an area with a dark background indicating the amount (%) of total HP lost.

So in order to auto HP pot we have to make a bot that checks for that dark color in that area.

GetMousePos
Retrieves the current position of the mouse cursor.

First thing we need to do is pick a spot on the HP/MP bar where the color changes from Red (HP) to the dark color (EMPTY/NO HP).

I picked this spot HERE. (see green dot)


We first have to figure out how to make the BOT focus on that position. We need to find the X and Y coordinates in order to do that. We will make a function for this first.

Code:
While 1
	sleep("1")
WEnd

Func _getDefault()
	
EndFunc
Then we add 2 variables. One for the X coordinate and one for the Y.
Code:
$x = 0
$y = 0

While 1
	sleep("1")
WEnd

Func _getDefault()
	
EndFunc
Now to get the actual coordinates using the MouseGetPos() function and set the new $x and $y variables to contain the position.
Code:
$x = 0
$y = 0

While 1
	sleep("1")
WEnd

Func _getDefault()
	$coord = MouseGetPos()
	$x = $coord[0]
	$y = $coord[1]
EndFunc
Pixel Search
Next we have to add something that continuously checks that position for a change in color.

Before we do that, we have to get the color of the pixel at that position. Which should some shade of red.

I am going to add it to the _getDefault() function because it is easier but there are different ways to do it. You can also add in if statement in the main function to check if $x or $y are anything but 0 (default).

set a variable outside of the function for the color.
Code:
$x = 0
$y = 0
$color = 0

While 1
	sleep("1")
WEnd

Func _getDefault()
	$coord = MouseGetPos()
	$x = $coord[0]
	$y = $coord[1]
EndFunc
Now lets use the Hex() function to get the hexadecimal color code value. It is a six character long code which represents a color.
Code:
$x = 0
$y = 0
$color = 0

While 1
	sleep("1")
WEnd

Func _getDefault()
	$coord = MouseGetPos()
	$x = $coord[0]
	$y = $coord[1]
	$color = Hex(PixelGetColor( $coord[0], $coord[1]), 6)
EndFunc
Next we need a hot key that will run the _getDefault() function and set the default/temporary variables to the real ones that you will use. This gives you as much time as you need to pick position on the HP bar. It wont automatically run when the program is started. We will use the HotKeySet() function.

Code:
HotKeySet("{NUMPADSUB}", "_getPosition")

$x = 0
$y = 0
$color = 0
$status = "off"

While 1
	sleep("1")
WEnd

Func _getDefault()
	$coord = MouseGetPos()
	$x = $coord[0]
	$y = $coord[1]
	$color = Hex(PixelGetColor( $coord[0], $coord[1]), 6)
	$status = "on"
EndFunc
Now when move your mouse to a position on the screen and press num pad - and it will set the $x, $y and $color for that spot.

Next we start the If statement. First we have to check the status. If the status is set to OFF, it will skip this code. If it is set to ON it will execute the code inside.


Next we have to add an if statement that checks that position to see if the $color has changed. We have to make a variable called $status and set its default value outside the loop to "off" so that the bot does not start.
Code:
HotKeySet("{NUMPADSUB}", "_getPosition")

$x = 0
$y = 0
$color = 0
$status = "off"

While 1
	sleep("1")
	If $status = "on" Then
		;code here
	EndIf

WEnd

Func _getDefault()
	$coord = MouseGetPos()
	$x = $coord[0]
	$y = $coord[1]
	$color = Hex(PixelGetColor( $coord[0], $coord[1]), 6)
	$status = "on"
EndFunc
Before we do the code inside the If statement we have to make a function llike _setDefault(). The only difference is that it will not get a new MousePos and it will save the Hex color to a new variable. We will use our current $x and $y positions. Don't forget to the declare $newColor outside of the function.

Code:
HotKeySet("{NUMPADSUB}", "_getDefault")

$x = 0
$y = 0
$color = 0
$newColor = 0
$status = "off"

While 1
	sleep("1")
	If $status = "on" Then
	EndIf

WEnd

Func _getDefault()
	$coord = MouseGetPos()
	$x = $coord[0]
	$y = $coord[1]
	$color = Hex(PixelGetColor( $coord[0], $coord[1]), 6)
	$status = "on"
EndFunc

Func _getCurrentColor($xDef, $yDef)
	$newColor = Hex(PixelGetColor( $xDef, $yDef), 6)
	Return ($newColor)
EndFunc
Now we continue with the If Statement. Now we add an if statement to check if the color has changed.

Code:
HotKeySet("{NUMPADSUB}", "_getDefault")

$x = 0
$y = 0
$color = 0
$newColor = 0
$status = "off"

While 1
	If $status = "on" Then
		If _getCurrentColor($x, $y) <> $color Then
			;code here
		EndIf
	EndIf
WEnd

Func _getDefault()
	$coord = MouseGetPos()
	$x = $coord[0]
	$y = $coord[1]
	$color = Hex(PixelGetColor( $coord[0], $coord[1]), 6)
	$status = "on"
EndFunc

Func _getCurrentColor($xDef, $yDef)
	$newColor = Hex(PixelGetColor( $xDef, $yDef), 6)
	Return ($newColor)
EndFunc
Now if the new color does not equal the old color it will execute the code. The code should be a Send() function. You should send the shorcut key for using your healing potion in-game. For this example we will use the number "1".
Code:
HotKeySet("{NUMPADSUB}", "_getDefault")

$x = 0
$y = 0
$color = 0
$newColor = 0
$status = "off"

While 1
	If $status = "on" Then
		If _getCurrentColor($x, $y) <> $color Then
			Send("1")
		EndIf
	EndIf
WEnd

Func _getDefault()
	$coord = MouseGetPos()
	$x = $coord[0]
	$y = $coord[1]
	$color = Hex(PixelGetColor( $coord[0], $coord[1]), 6)
	$status = "on"
EndFunc

Func _getCurrentColor($xDef, $yDef)
	$newColor = Hex(PixelGetColor( $xDef, $yDef), 6)
	Return ($newColor)
EndFunc
Now we are done. The BOT will spam the key 1 until the color is back to normal and it will start spamming again if it changes.

Last edited by TheForsaken; 01-27-2010 at 20:25.
TheForsaken is offline  
Thanks
90 Users
'Merica (11-20-2011), -leo6142- (12-04-2013), -Zombie-001- (01-22-2012), .Cdog (06-12-2011), 0Player (04-07-2014), Achat (04-12-2012), adri1205 (05-06-2014), Ahzsyjie (09-18-2010), allesweg... (08-07-2010), amnesi (10-22-2010), aragonik (01-22-2010), Artarex (07-30-2010), ax5 (01-31-2010), B0tCod3r (03-31-2010), Bogenkiller (05-15-2010), Bone-marrow (06-27-2013), Brand95 (11-11-2012), bsbsking17 (03-09-2012), Cheatengine1 (09-11-2011), Combat (11-21-2011), Cool841 (07-26-2014), Dacyon (09-29-2010), Daddy Neuland (11-02-2010), dakrmancz (03-03-2014), derrod (10-07-2012), disconackted (02-16-2014), dommerle (07-25-2011), dondale8 (05-21-2010), dr3amw4lker (05-25-2010), elloco@1 (04-14-2013), Evil_Warlock (04-14-2010), Fa111l (09-22-2010), Forfirith (10-01-2010), foxhound83 (09-20-2013), gamer96 (02-20-2012), HAcker240 (04-27-2011), hiflyer (04-08-2014), hoocrax (07-03-2011), Husk_One (07-13-2010), idna2241 (04-02-2010), Javierz (07-12-2011), JohnHeatz (09-15-2012), khiladi_726 (09-22-2013), Käsekuchen. (04-11-2010), l3obn4tzer (11-05-2011), Linoskoczek (08-20-2012), lordcis23 (07-23-2012), loretde (03-01-2010), LostHope. (08-14-2011), lukkigi (03-28-2010), makradesh (02-18-2011), marcelkd (11-27-2013), mdzulahzier (01-20-2014), menotu (02-27-2012), micron (09-24-2011), mono0 (10-11-2010), mooface (10-24-2010), mrapc (02-06-2011), myaero14 (03-11-2010), namanem (01-27-2011), Nelunia (01-08-2011), nixgibts (09-22-2011), nwomatt (12-19-2010), ouka (04-24-2011), Pirate Storm Player (06-01-2013), Professor Linebeck (12-02-2010), quanttron (08-19-2012), RedStarGer (05-07-2014), reversegamer90 (11-10-2012), RF1T3 (10-28-2012), Sarpa1053 (09-30-2010), sasukegamer (02-18-2012), sbob10 (02-16-2011), sefa1974 (08-03-2010), Shane¸ (07-26-2010), sido47 (02-13-2011), Sir Ryuuzaki (04-17-2010), Skyrok (06-28-2011), sloktok (08-28-2010), STdata (01-11-2012), tox124 (11-21-2013), Unredlich (06-11-2013), VzR (06-10-2010), Wellingtonmaru (07-18-2012), wurzes (03-02-2012), xX0815Xx (06-12-2010), Yarobe (04-21-2013), zCrossYuuki (07-12-2012), zero29 (10-22-2010), •Giant•Epic•Smiley• (10-03-2010)
Old 12-22-2009, 05:14   #5
Junior Member
 
Join Date: Apr 2006
Posts: 18
Received Thanks: 0
hi...i read them all and chapter 3 kinda short? im learning to do the timediff better than the sleep thanks!! gonna try that now
vtdrx is offline  
Old 01-17-2010, 19:28   #6
Member
 
Join Date: Oct 2009
Posts: 63
Received Thanks: 553
Quote:
Originally Posted by vtdrx View Post
hi...i read them all and chapter 3 kinda short? im learning to do the timediff better than the sleep thanks!! gonna try that now
What do you need to know? If you need any help just let me know. Post code.
TheForsaken is offline  
Thanks
8 Users
aragonik (01-22-2010), Bogenkiller (05-15-2010), Cool841 (07-26-2014), derrod (10-07-2012), dommerle (07-25-2011), macdowskie (06-14-2013), msashlesh (10-10-2013), Unredlich (06-11-2013)
Old 01-17-2010, 22:32   #7
Member
 
Join Date: Jan 2006
Posts: 81
Received Thanks: 18
hey forsaken nice tut

maybe u want add some code for pixelgetcolore, pixelsearch and maybe memory read

just advice XD
markusbab is offline  
Old 01-21-2010, 15:42   #8
ax5
Developer
 
Join Date: May 2009
Posts: 1,035
Received Thanks: 461
TheForsaken it would be good if you add imgaes on CHAPTER and CHAPTER 3

only a tip
ax5 is offline  
Thanks
9 Users
BAN420 (09-26-2010), coolfire10 (05-21-2012), dommerle (07-25-2011), mooface (10-24-2010), Namex1337 (10-11-2010), Sarpa1053 (09-30-2010), sido47 (02-13-2011), Superman44 (03-21-2010), TheDextrox (04-24-2010)
Old 01-22-2010, 20:45   #9
[*****]BosKx
 
Join Date: Sep 2009
Posts: 134
Received Thanks: 36
Blog Entries: 1
o.O i did it it says star or stop XD i think in me mind Good job But..
XDDD i dont knwo how i did it XDD
aragonik is offline  
Old 01-26-2010, 05:15   #10
Member
 
Join Date: Oct 2009
Posts: 63
Received Thanks: 553
I'll try and add pixel search in Chapter 3 if I find some free time this weekend. It can be used for auto healing.
TheForsaken is offline  
Thanks
4 Users
ax5 (01-26-2010), Blackfaun (04-21-2012), marcelkd (11-27-2013), Skyrok (06-28-2011)
Reply

Tags
autoit, bot, forsaken, hack, tutorial

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Video Tutorial] - Very Easy Tutorial How to make your Own Wallhack in C++ babyface21 Soldier Front Hacks, Bots, Cheats & Exploits 16 09-01-2012 03:14
[[Tutorial]] how to make your own hacks with VB fireblad3 WarRock Hacks, Bots, Cheats & Exploits 81 03-13-2011 09:06
[TUTORIAL] How To Make A UCE !!! wsuo Maple Story 23 08-12-2010 23:14
My First tutorial How to make 20K GP in 5 Min elmo3zeb CrossFire 26 08-05-2010 23:59
[Tutorial] How To Make Around $50 A Day deadessence Main 4 01-30-2010 11:37



All times are GMT +2. The time now is 09:33.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.