Jump to content
Sign in to follow this  
Humper

Pixel based bot

Recommended Posts

Humper

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]

Share this post


Link to post
Share on other sites
d3mon

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

Share this post


Link to post
Share on other sites
d3mon

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

Share this post


Link to post
Share on other sites
Humper

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

They also move.

Posted Image


[center][/center]

Share this post


Link to post
Share on other sites
d3mon

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

Share this post


Link to post
Share on other sites
Humper

Thank you very very much! I will try this later on, gonna party now when its "Rock off" http://www.rockoff.nu/.

Festival here, I msg here for more questions if needed.

Regards Humper


[center][/center]

Share this post


Link to post
Share on other sites
Humper

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]

Share this post


Link to post
Share on other sites
Golbez

search is your friend

help file is also your friend

and to find colors autoit window tool will help muttley

Share this post


Link to post
Share on other sites
Humper

$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]

Share this post


Link to post
Share on other sites
Humper

Ehm still need some help at this.


[center][/center]

Share this post


Link to post
Share on other sites
Humper

I get this error, Do i need any code after the color and the color what should it be in? (hex?)

Posted Image

Regards Humper


[center][/center]

Share this post


Link to post
Share on other sites
d3mon

I get this error, Do i need any code after the color and the color what should it be in? (hex?)

Posted Image

Regards Humper

Why your color have $ like a variable do :

$PixelSearch(0,0,@DesktopWidth,@DesktopHeight,"0xff8800")

No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE

Share this post


Link to post
Share on other sites
Humper

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]

Share this post


Link to post
Share on other sites
ofLight

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

Share this post


Link to post
Share on other sites
Humper

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]

Share this post


Link to post
Share on other sites
d3mon

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

Edited by d3mon

No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE

Share this post


Link to post
Share on other sites
d3mon

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

Share this post


Link to post
Share on other sites
FreeFry

You should specify the hex color 0xFFEE00, instead of "0xFFEE00" as PixelSearch is expecting a number, not a string. muttley

Share this post


Link to post
Share on other sites
Humper

Ok how is this possible?

Regards Humper

Btw thanks for all the amazing help I get from you guys!

Edited by Humper

[center][/center]

Share this post


Link to post
Share on other sites
FreeFry

Ok how is this possible?

Regards Humper

Btw thanks for all the amazing help I get from you guys!

How's what possible?

Share this post


Link to post
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
Sign in to follow this  

×