Humper Posted July 20, 2008 Posted July 20, 2008 (edited) 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.Also when the number by the pink rectangle turns either 0 or under 9 (less then xx numbers) to press F12.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 July 20, 2008 by Humper [center][/center]
d3mon Posted July 20, 2008 Posted July 20, 2008 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
d3mon Posted July 20, 2008 Posted July 20, 2008 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
Humper Posted July 20, 2008 Author Posted July 20, 2008 Ok but I want on this place to seach for the orange and brown and red color.They also move. [center][/center]
d3mon Posted July 20, 2008 Posted July 20, 2008 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
Humper Posted July 20, 2008 Author Posted July 20, 2008 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]
Humper Posted July 20, 2008 Author Posted July 20, 2008 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]
Golbez Posted July 20, 2008 Posted July 20, 2008 search is your friend help file is also your friend and to find colors autoit window tool will help muttley
Humper Posted July 20, 2008 Author Posted July 20, 2008 $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]
Humper Posted July 21, 2008 Author Posted July 21, 2008 Ehm still need some help at this. [center][/center]
Humper Posted July 21, 2008 Author Posted July 21, 2008 I get this error, Do i need any code after the color and the color what should it be in? (hex?)Regards Humper [center][/center]
d3mon Posted July 21, 2008 Posted July 21, 2008 I get this error, Do i need any code after the color and the color what should it be in? (hex?) 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
Humper Posted July 21, 2008 Author Posted July 21, 2008 (edited) 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 July 21, 2008 by Humper [center][/center]
ofLight Posted July 21, 2008 Posted July 21, 2008 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
Humper Posted July 21, 2008 Author Posted July 21, 2008 (edited) 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 July 21, 2008 by Humper [center][/center]
d3mon Posted July 21, 2008 Posted July 21, 2008 (edited) No let it I think he find another color so can you do sreenshoot of all your game for better pixelsearch, thanks Edited July 21, 2008 by d3mon No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE
d3mon Posted July 21, 2008 Posted July 21, 2008 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
FreeFry Posted July 21, 2008 Posted July 21, 2008 You should specify the hex color 0xFFEE00, instead of "0xFFEE00" as PixelSearch is expecting a number, not a string. muttley
Humper Posted July 22, 2008 Author Posted July 22, 2008 (edited) Ok how is this possible? Regards Humper Btw thanks for all the amazing help I get from you guys! Edited July 22, 2008 by Humper [center][/center]
FreeFry Posted July 22, 2008 Posted July 22, 2008 Ok how is this possible?Regards HumperBtw thanks for all the amazing help I get from you guys!How's what possible?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now