|
You last visited: Today at 03:45
Advertisement
Tutorial: how to write a pixelbot in Autoit
Discussion on Tutorial: how to write a pixelbot in Autoit within the Coding Tutorials forum part of the General Coding category.
08/27/2013, 02:21
|
#1
|
elite*gold: 20
Join Date: Dec 2012
Posts: 725
Received Thanks: 333
|
Tutorial: how to write a pixelbot in Autoit
Hello!
Since the newest updates, pixelbots have been getting more popular. I noticed that there are not many Autoit tutorials for a Darkorbit pixelbot, so I decided to make one  This is my first tutorial, and I am still learning Autoit, so bear with me...
Before I begin, you should have Autoit downloaded. Have SciTE.exe and Au3Info.exe open (both can be found in the Autoit folder).
First we need to make a while statement:
This puts the code into a loop and makes it keep running.
Next, we need to tell the bot to search for Bonusboxes around your ship:
Code:
While 1
$Box = PixelSearch(80,85,1745,1050,0xFFFFDD)
WEnd
This line of code tells the bot the area it should search for a pixel color. You declare the variable "$box" and tell the bot to search for it.
To find the color of a bonus box (or palladium  ) use the au3info window:
Simply click and drag the crosshairs/target to whatever you want to be collected and it will tell you the pixel color.
NOTE: Your info window must be on the "mouse" tab!
Then find the coordinates for the top left and bottom right of your collecting area with the info window:
Here is where everything goes:
Code:
$variablename = PixelSearch([top left x coord],[top left y coord],[bottom right x coord],[bottom right y coord],[Pixel Color])
Next, we need to add code of what the bot should do if it spots the pixel:
Code:
While 1
$Box = PixelSearch(80,85,1745,1050,0xFFFFDD)
If IsArray($Box) Then
MouseMove($Box[0],$Box[1],0)
MouseClick("left")
Sleep(1750)
WEnd
Basically, the bot will move the cursor to the pixel and click. The sleep time is the amount of time needed for your ship to collect the box/resource.
Next we need to make the ship move if there is nothing to collect:
Code:
While 1
$Box = PixelSearch(80,85,1745,1050,0xFFFFDD)
If IsArray($Box) Then
MouseMove($Box[0],$Box[1],0)
MouseClick("left")
Sleep(1750)
Else
Opt("MouseCoordMode", 1)
MouseMove(int(Random(1390,1580)), int(Random(805,915)), 0)
MouseClick("left")
Sleep(2000)
EndIf
WEnd
The "Else" statement tells the bot to move if no box/resource is spotted. The "Sleep(2000)" is the timing between each click on the minimap. Make sure to have "1" beside MouseCoordMode, otherwise it may not work. In this line:
Code:
MouseMove(int(Random(1390,1580)), int(Random(805,915)), 0)
you must use your info window to find the coords of your minimap.
First find the minimum x coord of the minimap (the left side)
Then find the maximum x coord of the minimap (the right side)
Next find the minimum y coord of the minimap (the top)
Lastly, find the maximum y coord of the mimimap (the bottom)
Now that we have all those coords, plug them into this line of code:
Code:
MouseMove(int(Random([minimum x],[maximum x])), int(Random([minimum y],[maximum y])), 0)
After that, you have a simple yet working boxbot. To make it collect palladium, switch the pixel color and change the minimap coordinates to accomodate the fog area instead of the entire minimap. Here is the whole source:
Code:
HotKeySet("{ESC}", "quit") ;ESC to quit
While 1
$Box = PixelSearch(80,85,1745,1050,0xFFFFDD)
If IsArray($Box) Then
MouseMove($Box[0],$Box[1],0)
MouseClick("left")
Sleep(1750)
Else
Opt("MouseCoordMode", 1)
MouseMove(int(Random(1390,1580)), int(Random(805,915)), 0)
MouseClick("left")
Sleep(2000)
EndIf
WEnd
Func quit()
Exit
EndFunc
Note: I added a hotkey (esc) to make the bot close itself out when you press it, that way you don't have to use task manager or anything like that 
Bot with added pause feature (Special thanks to Fluttershy)
Code:
#RequireAdmin
Global $pause = False
ProcessSetPriority("script name.exe",4) ;enter your script name in order to work
HotKeySet("{ESC}", "_quit") ;ESC to quit
HotKeySet("{F1}", "_Pause") ;F1 to pause
Opt("MouseCoordMode", 1)
While 1
If $pause = False Then
$Box = PixelSearch(80,85,1745,1050,0xFFFFDD)
If IsArray($Box) Then
MouseMove($Box[0],$Box[1],0)
MouseClick("left")
Sleep(1750)
Else
MouseMove(Random(1390,1580,1), Random(805,915,1), 0)
MouseClick("left")
Sleep(2000)
EndIf
Else
sleep(150)
EndIf
WEnd
Func _quit()
Exit
EndFunc
Func _Pause()
If $pause = True Then
$pause = False
ElseIf $pause = False Then
$pause = True
EndIf
EndFunc
Bot with other features (Timer, count of boxes collected, etc. Again, special thanks to Fluttershy)
Code:
#RequireAdmin
Global $pause = False
Global $count = 0
ProcessSetPriority("script name.exe",4)
HotKeySet("{ESC}", "_quit")
HotKeySet("{F1}", "_Pause")
Opt("MouseCoordMode", 1)
$Timer = TimerInit()
While 1
If $pause = False Then
$Box = PixelSearch(80,85,1745,1050,0xFFFFDD)
If IsArray($Box) Then
MouseMove($Box[0],$Box[1],0)
MouseClick("left")
Sleep(1750)
$count = $count + 1
Else
MouseMove(Random(1390,1580,1), Random(805,915,1), 0)
MouseClick("left")
Sleep(2000)
EndIf
Else
sleep(150)
EndIf
WEnd
Func _quit()
$Diff = TimerDiff($Timer)
$Diff = $Diff / 1000
MsgBox(0,"Boxes Collected","You collected ~ " & $count & " BonusBoxes " & @CRLF & "in ~ " & $Diff & " Seconds")
Exit
EndFunc
Func _Pause()
If $pause = True Then
$pause = False
ElseIf $pause = False Then
$pause = True
EndIf
EndFunc
Thanks to Forsaken and Dr.Toni for their tutorials and Fluttershy for adding features in the code. Feel free to pm me any questions that you have.
|
|
|
09/15/2013, 01:12
|
#2
|
Moderator
elite*gold: 2072
Join Date: Mar 2013
Posts: 10,509
Received Thanks: 6,644
|
You learned from my Tutorial... Amazing
|
|
|
09/15/2013, 20:01
|
#3
|
elite*gold: 20
Join Date: Dec 2012
Posts: 725
Received Thanks: 333
|
Quote:
Originally Posted by Dг.Tσпi™
You learned from my Tutorial... Amazing 
|
Your tutorial helped a lot, thanks a bunch for posting it.
|
|
|
09/15/2013, 20:53
|
#4
|
elite*gold: 0
Join Date: Oct 2012
Posts: 295
Received Thanks: 32
|
One question what about a npc pixel bot? U can make a tutorial for it ? Or someone ?
|
|
|
09/15/2013, 21:26
|
#5
|
Moderator
elite*gold: 2072
Join Date: Mar 2013
Posts: 10,509
Received Thanks: 6,644
|
I could do it yes... but you have to learn Pixelsearch and imagesearch and you can do it yourself
|
|
|
09/15/2013, 22:34
|
#6
|
elite*gold: 20
Join Date: Dec 2012
Posts: 725
Received Thanks: 333
|
Quote:
Originally Posted by MuPowe
One question what about a npc pixel bot? U can make a tutorial for it ? Or someone ?
|
Try putting NPCs on low and inputting the pixel color from lordakias or streuners. Like Dr.Toni said, it would probably be better to use imagesearch. Perhaps I should make another tutorial
|
|
|
09/15/2013, 23:04
|
#7
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
Dont convert the random floating number into integer . use the third parameter its much faster .
dont declare the Opt in a while . it needs to put at start of a func or on script start .
use the instant miusemove parameter .
give the while $pause = true and change it in the while to false (a little suggestion to make the code better)
|
|
|
09/15/2013, 23:25
|
#8
|
elite*gold: 20
Join Date: Dec 2012
Posts: 725
Received Thanks: 333
|
Quote:
Originally Posted by »FlutterShy™
Dont convert the random floating number into integer . use the third parameter its much faster .
dont declare the Opt in a while . it needs to put at start of a func or on script start .
use the instant miusemove parameter .
give the while $pause = true and change it in the while to false (a little suggestion to make the code better)
|
Okay, I understood a bit of what you said...
-Change MouseMove($Box[0],$Box[1],1) to MouseMove($Box[0],$Box[1],0)
-Change MouseMove(int(Random(1390,1580)), int(Random(805,915)), 1) to MouseMove(int(Random(1390,1580)), int(Random(805,915)), 0)
-Move Opt("MouseCoordMode", 1) Above the while loop
I am not sure about this, but are you also suggesting:
-Change MouseMove(int(Random(1390,1580)), int(Random(805,915)), 0) to MouseMove(Random(1390,1580), Random(805,915), 0)
-Change While 1 to While <$pause=true> (In which case, would I have to declare $pause somewhere above the while?)
Thanks for the suggestions, please correct me if I am wrong.
|
|
|
09/16/2013, 12:37
|
#9
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
i wrote that on my smartphone so here is what i mean exactly
That will be better
Code:
#RequireAdmin
Global $pause = False
ProcessSetPriority("script name.exe",4)
HotKeySet("{ESC}", "_quit")
HotKeySet("{F1}", "_Pause")
Opt("MouseCoordMode", 1)
While 1
If $pause = False Then
$Box = PixelSearch(80,85,1745,1050,0xFFFFDD)
If IsArray($Box) Then
MouseMove($Box[0],$Box[1],0)
MouseClick("left")
Sleep(1750)
Else
MouseMove(Random(1390,1580,1), Random(805,915,1), 0)
MouseClick("left")
Sleep(2000)
EndIf
Else
sleep(150)
EndIf
WEnd
Func _quit()
Exit
EndFunc
Func _Pause()
If $pause = True Then
$pause = False
ElseIf $pause = False Then
$pause = True
EndIf
EndFunc
|
|
|
09/16/2013, 16:09
|
#10
|
elite*gold: 20
Join Date: Dec 2012
Posts: 725
Received Thanks: 333
|
Quote:
Originally Posted by »FlutterShy™
i wrote that on my smartphone so here is what i mean exactly
That will be better
Code:
#RequireAdmin
Global $pause = False
ProcessSetPriority("script name.exe",4)
HotKeySet("{ESC}", "_quit")
HotKeySet("{F1}", "_Pause")
Opt("MouseCoordMode", 1)
While 1
If $pause = False Then
$Box = PixelSearch(80,85,1745,1050,0xFFFFDD)
If IsArray($Box) Then
MouseMove($Box[0],$Box[1],0)
MouseClick("left")
Sleep(1750)
Else
MouseMove(Random(1390,1580,1), Random(805,915,1), 0)
MouseClick("left")
Sleep(2000)
EndIf
Else
sleep(150)
EndIf
WEnd
Func _quit()
Exit
EndFunc
Func _Pause()
If $pause = True Then
$pause = False
ElseIf $pause = False Then
$pause = True
EndIf
EndFunc
|
Very nice, you added a pause feature. I'll add it to the first post and give you credit. There are other things that can be added such as timers instead of sleep commands, imagesearch for minimap coords, select area, etc. This is just a starting point for now.
|
|
|
09/16/2013, 20:08
|
#11
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
when i have time i post new versions of my script ^^
pixelbots like this arent needed everymore , talanted coders will use trapdoor
#Updates :
-Added Timer (Time Difference between start and exit)
-Added counter for collected boxes
Code:
#RequireAdmin
Global $pause = False
Global $count = 0
ProcessSetPriority("script name.exe",4)
HotKeySet("{ESC}", "_quit")
HotKeySet("{F1}", "_Pause")
Opt("MouseCoordMode", 1)
$Timer = TimerInit()
While 1
If $pause = False Then
$Box = PixelSearch(80,85,1745,1050,0xFFFFDD)
If IsArray($Box) Then
MouseMove($Box[0],$Box[1],0)
MouseClick("left")
Sleep(1750)
$count = $count + 1
Else
MouseMove(Random(1390,1580,1), Random(805,915,1), 0)
MouseClick("left")
Sleep(2000)
EndIf
Else
sleep(150)
EndIf
WEnd
Func _quit()
$Diff = TimerDiff($Timer)
$Diff = $Diff / 1000
MsgBox(0,"Boxes Collected","You collected ~ " & $count & " BonusBoxes " & @CRLF & "in ~ " & $Diff & " Seconds")
Exit
EndFunc
Func _Pause()
If $pause = True Then
$pause = False
ElseIf $pause = False Then
$pause = True
EndIf
EndFunc
|
|
|
09/17/2013, 02:51
|
#12
|
elite*gold: 20
Join Date: Dec 2012
Posts: 725
Received Thanks: 333
|
Quote:
Originally Posted by »FlutterShy™
when i have time i post new versions of my script ^^
pixelbots like this arent needed everymore , talanted coders will use trapdoor
#Updates :
-Added Timer (Time Difference between start and exit)
-Added counter for collected boxes
Code:
#RequireAdmin
Global $pause = False
Global $count = 0
ProcessSetPriority("script name.exe",4)
HotKeySet("{ESC}", "_quit")
HotKeySet("{F1}", "_Pause")
Opt("MouseCoordMode", 1)
$Timer = TimerInit()
While 1
If $pause = False Then
$Box = PixelSearch(80,85,1745,1050,0xFFFFDD)
If IsArray($Box) Then
MouseMove($Box[0],$Box[1],0)
MouseClick("left")
Sleep(1750)
$count = $count + $count
Else
MouseMove(Random(1390,1580,1), Random(805,915,1), 0)
MouseClick("left")
Sleep(2000)
EndIf
Else
sleep(150)
EndIf
WEnd
Func _quit()
$Diff = TimerDiff($Timer)
$Diff = $Diff / 1000
MsgBox(0,"Boxes Collected","You collected ~ " & $count & " BonusBoxes " & @CRLF & "in ~ " & $Diff & " Seconds")
Exit
EndFunc
Func _Pause()
If $pause = True Then
$pause = False
ElseIf $pause = False Then
$pause = True
EndIf
EndFunc
|
More code? Thanks  , I will add this later.
You are probably right though, Ink's dll will make the best pixelbots (vm is inefficient), but I can't see the harm in learning a little autoit. You clearly know autoit well, I appreciate the advice and sources. Btw, doesn't "4" in the process priorities add cpu-usage?
|
|
|
09/17/2013, 14:04
|
#13
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
Quote:
Originally Posted by Bone-marrow
Btw, doesn't "4" in the process priorities add cpu-usage?
|
yes but make script faster ^^
|
|
|
09/30/2013, 06:06
|
#14
|
elite*gold: 0
Join Date: Sep 2013
Posts: 3
Received Thanks: 0
|
Is there a way to add multiple pixels that it can search for? Cause right now, it only pick ups like 1/20 of the boxes it finds xD
EDIT: Nvm, figured it out ^.^
Can you fix the bonus box counter though? it doesent seem to work. tyty
|
|
|
09/30/2013, 06:12
|
#15
|
elite*gold: 20
Join Date: Dec 2012
Posts: 725
Received Thanks: 333
|
Quote:
Originally Posted by sasdfasdfas
Is there a way to add multiple pixels? Cause right now, it only pick ups like 1/20 of the boxes it finds xD
|
You can add shade variation or have multiple pixel searches.
|
|
|
 |
|
Similar Threads
|
[TUT] How to write your own Pixelbot [AutoIT]
06/22/2017 - Coding Tutorials - 37 Replies
At first you need to find the right pixel colour...
We will do it with the AutoIT Tool:
AutoIT Window Info
http://picpanda.com/images/xk1z5i2yeot12mc1zn2_th umb.png
When we found the pixel we need to add that your ship moves:
|
Autoit Pixelbot für Browsergame
12/05/2012 - AutoIt - 5 Replies
Hy leute suche ein paar leute die lust und laune
haben mit mir einen Pixelbot für das Spiel Darkorbit zu machen.
Was ihr können müsst:
ihr solltet etwas erfahrung haben
|
AutoIT PixelBot Hilfe
03/01/2010 - AutoIt - 3 Replies
Hey ich hätte mal ein paar Fragen...
Also wie ja oben steht brauche ich Hilfe bei einem PixelBot zum Farmen.
Der Bot soll davon unterscheiden können ob er einen Mob anvisiert hat oder nicht.
Das funktioniert bei meinem Bot folgendermaßen:
Er Scannt oben die Farbe von der HP Leiste des Monsters (Rot),wenn diese vorhaden ist dann fängt er an die Skills auszuführen und zu looten.
Wenn sie nicht vorhaden ist drückt er einfach TAB um ein Mob anzuvisieren...und...danach...naja passiert gar...
|
All times are GMT +1. The time now is 03:45.
|
|