Smithy963 Posted October 27, 2006 Share Posted October 27, 2006 (edited) I am new to AutoIt i have a little knowledge on programming, with Python and a little Visual Basic. I think i understand the mechanics behind programming. Bearing that in mind i would like some help. I am in the process of planning a bot for a game. and for this bot to function, I need to use 'get pixel'. at this point in time i do not understand the 'get pixel' function and i am asking if it is possible for somebody to tell me the limitations and capabilities and generally how it works please? Also I would like know if it is possible or if it would consume too much power to constantly analyze 4-5 areas (lines of pixels, boxes of pixels) for certain colours and/or changes. Thank you very much in advance, for any and all help with this subject. Edited October 27, 2006 by Smithy963 Link to comment Share on other sites More sharing options...
PaulIA Posted October 27, 2006 Share Posted October 27, 2006 Start out by looking for "PixelSearch" in the help file and here on the forum. There are (unfortunately) a lot of bot scripts around here that you can look at for examples. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
Smithy963 Posted October 27, 2006 Author Share Posted October 27, 2006 (edited) ok thank you very much. i will do that right now. also i would like to ask if pixelsearch can be used in if statements for example, this is a more VB version for simplicity, sorry. If Pixelsearch (pixel position) = ( pixel colour) Then (perform this operation) Else Pixelsearch (pixel position) = (pixel colour) Then (perform another operation) End if End Thanks again. Edited October 27, 2006 by Smithy963 Link to comment Share on other sites More sharing options...
lopolop Posted October 27, 2006 Share Posted October 27, 2006 (edited) im pretty sure you cant check if pixelsearch is a color.. Pixelsearch.. searchs a Set of pixels you put in(a box) and if it finds that pixel it will tell you the X & Y coordinates... you probably want PixelGetColor() or... you can look at If Not @Error Then Edited October 27, 2006 by lopolop Link to comment Share on other sites More sharing options...
Kohr Posted October 27, 2006 Share Posted October 27, 2006 Example using PixelSearch and PixelGetColor $NoBar = PixelGetColor(10, 10) If Hex($NoBar, 6) = "FF0000" Then ConsoleWrite("Color found" & @CRLF) Else ConsoleWrite("Color NOT found" & @CRLF) EndIf $NoBar = PixelSearch(10, 10, 100, 100, 0xFF0000, 1) If Not @error Then ConsoleWrite("Color found" & @CRLF) Else ConsoleWrite("Color NOT found" & @CRLF) EndIf Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Smithy963 Posted October 27, 2006 Author Share Posted October 27, 2006 ok so your saying to me that pixelsearch and pixelgetcolor are opposite of each other, pixelsearch i give a colour and it gives me the coordinates? pixelgetcolour i give a coordinates and it tells me the colour it finds ? see, i need something that will search a spot (i know where the spot i want to search is) then i want it to compare that pixel it finds with the colour i will specify, then if the colour it finds is the same as the colour i told it. it will do something but if it doesnt then it must skip onto the next line or repeat. basically, i just need to make sure that this is possible before i start getting too much into this then i will start my learning process and stop acting like a noob and risk getting flamed. Link to comment Share on other sites More sharing options...
Kohr Posted October 27, 2006 Share Posted October 27, 2006 see, i need something that will search a spot (i know where the spot i want to search is)then i want it to compare that pixel it finds with the colour i will specify, then if the colour it finds is the same as the colour i told it. it will do something but if it doesnt then it must skip onto the next line or repeat.How is this any different than using PixelGetColor?You want to search a spot (enter x,y in PixelGetColor).Compare what it finds with the colour you specify(it finds FF0000 and you specify FF0000 then it does x else do y.)Am I misunderstanding?Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
lopolop Posted October 27, 2006 Share Posted October 27, 2006 So you could do this... While 1 $Var = Pixelsearch(10, 10, 100, 100, 0xFF0000, 1) If Not @Error Then msgbox(" 1, "Color!", "Color Found at " & $Var[0] & ", " & $Var[1]) ExitLoop EndIf WEnd This will repeate until The color is found.. Hey lol is color spelt color... or Colour? Link to comment Share on other sites More sharing options...
Smithy963 Posted October 27, 2006 Author Share Posted October 27, 2006 oh no, the idea is.... i want to find a fishing rod, lol. and if the fishing rod is leaning right i must press left, if the fishing rod is leaning left i must press right. now, the idea is i get 3 pixel positions from my screen ( rod left, rod right, rod central) each of these spots has a possibility of being 2 colours each, the rod colour, and back ground colour. i need autoit to continuosly search these 3 spots if it finds the rod colour on the left. it presses right, rod on the right presses left... you get the idea. so from experiance with VB im guessing my code should look a little like this ,but a lot more complex $rodcolor = FFFFFF If <pixel position(right side)> = $rodcolor then press and hold left elseif <pixel position(left side)> = $rodcolor then press and hold right else do nothing endif fish is caught as you can see, some familiarity with the code is to be desired. but i think i got the idea? if that makes sense? and could somebody also tell me how to put my code on inset like that please, im thinkin ive got alot of variables and pixelgetcolour problems im going to need help with. Link to comment Share on other sites More sharing options...
Smithy963 Posted October 27, 2006 Author Share Posted October 27, 2006 and also im trying to "americanise" my writing but i keep going on "autopilot" and writing the correct way for my counry (UK), also i would like to thank you guys. you have helped an awful lot, in a very short time, leaving me with a good impression of this place, within 6hours or so of me joining thank you very much Link to comment Share on other sites More sharing options...
Kohr Posted October 27, 2006 Share Posted October 27, 2006 (edited) Basic idea to get you started. ;left $x1 = 100 $y1 = 100 ;center $x2 = 105 $y2 = 100 ;right $x3 = 110 $z3 = 100 $rodcolor = "FFFFFF" While 1 $Center = Hex(PixelGetColor($x2, $y2),6) If $Center <> $rodcolor Then ;rod not in center $Left = Hex(PixelGetColor($x1, $y1),6) If $Left = $rodcolor Then ;rod is on left Send("{RIGHT}") EndIf $Right = Hex(PixelGetColor($x3, $y3),6) If $Right = $rodcolor Then ;rod is on right Send("{LEFT}) EndIf EndIf ;need some way to get out of this - probably HotKeySet WEnd Kohr Edited October 27, 2006 by Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Smithy963 Posted October 27, 2006 Author Share Posted October 27, 2006 no no, that is perfect. the fully finished program i am making will be 1 huge loop, with a lot of mini loops inside, and the idea is. 1. i check bait 2. check rod 3. cast rod 4. 4 detect when fish is on the line 5. do this what we have been chatting about (the hard part to me lol) 6. while doing the reeling in checking the fishes health at the same time 7. when fishes health hits 0 press enter 8. sort out inventory 9. restart from number 1. ive started drawing out a big visual idea of how i want it too work. say if the fish is too big to cancel, if inventory is full close game. im gonna start on something simple like to wait until game has loaded up and to then cast rod. and reel it in when health equals 0. then build on it more an more until perfect to do the entire process on its own and finally thank you very much for your posts, aswell as telling me that what i wish to achieve is possible youve also gave me a starting point. so thank you very very much Smithy963. Link to comment Share on other sites More sharing options...
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