Jump to content

Help with "get pixel"


Recommended Posts

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 by Smithy963
Link to comment
Share on other sites

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. :whistle:

Edited by Smithy963
Link to comment
Share on other sites

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 by lopolop
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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 :whistle: ,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

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 :whistle:

thank you very much ;)

Link to comment
Share on other sites

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 by Kohr
Link to comment
Share on other sites

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

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...