Jump to content

Pixel based bot


Recommended Posts

Hello I want to make a pixel based bot, I never used autoit because and Im wondering if I could get some help here.

This is what I would like to do:

I want it to seach for this colors then press left/right (depends on where they are) and when they are close enought start pressing ctrl.

Posted Image

Posted Image

Posted Image

Also when the number by the pink rectangle turns either 0 or under 9 (less then xx numbers) to press F12.

Posted Image

Could someone please help me with a tutorial or some scripts for this?

I don't know if someone even got what I was saying but just write here and tell me what you didn't get.

Thanks in advance!

Regards Humper

Edited by Humper

[center][/center]

Link to comment
Share on other sites

Yes you can do pixelsearch,

First check position of a pixel you want to get hexadecimal color and search it :

$pixelcolor=PixelGetColor($x,$y) ;Replace $x and $y by the pixel position of the color you want to know ==> Then you have color don't repeat this action
MsgBox(0,"",$pixelcolor) ;Show pixel color

;Then you have pixel Color ($pixelcolor)
$pixelSearch=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$pixelcolor) ;Search the pixelcolor => Start at 0pixel by 0pixel and finish at your DesktopWidth by DesktopHeight
;(replace $pixelcolor by your color found before)

If IsArray($pixelSearch)=1 Then ;If the pixel color has been found then
MouseClick("left",$pixelSearch[0],$pixelSearch[1],1,0) ;Click with left mouse at pixelfound position (with 0 speed = MAX)
EndIf
No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE
Link to comment
Share on other sites

for your game move your player :

$pixelcolor=PixelGetColor($x,$y) ;Replace $x and $y by the pixel position of the color you want to know ==> Then you have color don't repeat this action
MsgBox(0,"",$pixelcolor) ;Show pixel color

;Then you have pixel Color ($pixelcolor)
$pixelSearch=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$pixelcolor) ;Search the pixelcolor => Start at 0pixel by 0pixel and finish at your DesktopWidth by DesktopHeight
;(replace $pixelcolor by your color found before)

If IsArray($pixelSearch)=1 Then ;If the pixel color has been found then
$pixelcolorplayer=PixelGetColor($x,$y) ;Replace $x and $y by the pixel position of the color you want to know ==> Then you have color don't repeat this action
MsgBox(0,"",$pixelcolorplayer) ;Show pixel color

;Then you have pixel Color ($pixelcolorplayer)
$pixelSearchPlayer=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$pixelcolorplayer) ;Search the pixelcolor => Start at 0pixel by 0pixel and finish at your DesktopWidth by DesktopHeight
;(replace $pixelcolorplayer by your color found before)
EndIf

If IsArray($pixelSearch)=1 Then ;If the pixel color for player has been found then
If $pixelsearchplayer[0]>$pixelsearch[0] Then ;If the animal is on left by the player then
Do
Send("{LEFT}")
Until $pixelsearchplayer[0]=$pixelsearch[0]+50 ;When the player is near animal by 50pixel
Send("{LCTRL}")
EndIf

If $pixelsearchplayer[0]<$pixelsearch[0] Then ;If the animal is on right by the player then
Do
Send("{RIGHT}")
Until $pixelsearchplayer[0]=$pixelsearch[0]-50 ;When the player is near animal by -50pixel
Send("{RCTRL}")
EndIf
EndIf
No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE
Link to comment
Share on other sites

They also move.

For autoit that's not a problem in 0.01sec your player will move to kill animal...

Ok but I want on this place to seach for the orange and brown and red color.

For colors use pixelgetcolor
No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE
Link to comment
Share on other sites

How I fix this?

Also who I add more colors and what color it shoud look for first?

$pixelSearch=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$ff8800)

If IsArray($pixelSearch)=1 Then;If the pixel color has been found then
MouseClick("left",$pixelSearch[0],$pixelSearch[1],1,0);Click with left mouse at pixelfound position (with 0 speed = MAX)
EndIf

[center][/center]

Link to comment
Share on other sites

$pixelSearch=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$0xff8800)

DesktopWidth by DesktopHeight, should I change them?

and the color is that one that is there. (0xff8800)

Sorry for making this hard, but this is the first time I work with autoit.

[center][/center]

Link to comment
Share on other sites

Thanks!! Works now, could you post a link for common codes.

Regards Humper

Edit, a few more questions, how i make the command to loop and how i make a delay before it starts?

Edited by Humper

[center][/center]

Link to comment
Share on other sites

You Can Use While command for looping and Sleep() for a delay, Examples of how to use can be found in the Help document.

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

Is it possible to change "DesktopWidth and Height to a value instead?

Also is it just to change the 0,0?

$pixelSearch=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,"0xFFEE00");Search the pixelcolor => Start at 0pixel by 0pixel and finish at your DesktopWidth by DesktopHeight
;(replace $pixelcolor by your color found before)

If IsArray($pixelSearch)=1 Then;If the pixel color has been found then

;Then you have pixel Color ($pixelcolorplayer)
$pixelSearchPlayer=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,"0xCC8888");Search the pixelcolor => Start at 0pixel by 0pixel and finish at your DesktopWidth by DesktopHeight
;(replace $pixelcolorplayer by your color found before)
EndIf

If IsArray($pixelSearch)=1 Then;If the pixel color for player has been found then
If $pixelsearchplayer[0]>$pixelsearch[0] Then;If the animal is on left by the player then
Do
Send("{LEFT}")
Until $pixelsearchplayer[0]=$pixelsearch[0]+50;When the player is near animal by 50pixel
Send("{LCTRL}")
EndIf

If $pixelsearchplayer[0]<$pixelsearch[0] Then;If the animal is on right by the player then
Do
Send("{RIGHT}")
Until $pixelsearchplayer[0]=$pixelsearch[0]-50;When the player is near animal by -50pixel
Send("{RCTRL}")
EndIf
EndIf

I this script doesn't work for me, it starts running but doesn't stop.

I think it finds something else in the same color but im not sure.

Edited by Humper

[center][/center]

Link to comment
Share on other sites

No let it I think he find another color so can you do sreenshoot of all your game for better pixelsearch, thanks

Anyway for that the script was wrong I changed it :

#include <Misc.au3> ;For _IsPressed Function
$pixelSearch=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,"0xFFEE00");Search the pixelcolor => Start at 0pixel by 0pixel and finish at your DesktopWidth by DesktopHeight
;(replace $pixelcolor by your color found before)

If IsArray($pixelSearch)=1 Then;If the pixel color has been found then

;Then you have pixel Color ($pixelcolorplayer)
$pixelSearchPlayer=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,"0xCC8888");Search the pixelcolor => Start at 0pixel by 0pixel and finish at your DesktopWidth by DesktopHeight
;(replace $pixelcolorplayer by your color found before)
EndIf

If IsArray($pixelSearchPlayer)=1 Then;If the pixel color for player has been found then
Do
$pixelSearch=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,"0xFFEE00") ;Always check for moving of animal
$pixelSearchPlayer=PixelSearch(0,0,@DesktopWidth,@DesktopHeight,"0xCC8888") ;Always check for moving of player

If $pixelsearchplayer[0]>$pixelsearch[0] Then;If the animal is on left by the player then
Do
Send("{LEFT}")
Until $pixelsearchplayer[0]=$pixelsearch[0]+50;When the player is near animal by 50pixel
Send("{LCTRL}")
EndIf

If $pixelsearchplayer[0]<$pixelsearch[0] Then;If the animal is on right by the player then
Do
Send("{RIGHT}")
Until $pixelsearchplayer[0]=$pixelsearch[0]-50;When the player is near animal by -50pixel
Send("{RCTRL}")
EndIf
Until _IsPressed("11"); CTRL key has been pressed by script
EndIf
No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...