Jump to content

PixelGetColor problems!


Recommended Posts

Hello all,

My first post on the forum! :)

I've been having a problem with PixelGetColor, i tried  to look it up myself so i can learn in the process. Despite the efforts that i have made, i'm still not there. 

So first i'll explain what i'm trying to do; i want to let my script wait/loop until there is a change in PixelGetColor. I've been testing it out with what i have found out myself, so i have put my PixelGetColor in a Do - Until loop. But it either completes it instantaneously when it is still the same color or it just keeps waiting on a change when there has already been a color change.

So i'm real confused. I've been trying out different codes out but i'm guessing my stuff ain't right cause i've been messing around with it too much.

So if it is possible, a little guidance in the right direction, please! 

 

I'll put it in example parts with my questions underneathe, because i have different ones that i have questions about;

Example 1 :    

------------------------------------------------------------------------

Func ColorLeft ()

Do

   $pixel = PixelGetColor(804,586)

   Sleep(100)

Until $pixel = 0x855230

EndFunc

------------------------------------------------------------------------

Now this one sometimes works as intended, but 90% of the time it doesn't notice the color change of the pixel or indicates that it is the same color. So it just keeps waiting. Is the pixel size too small or something?

 

Because of that, i've been trying it out in a diffirent way

Example 2 :

------------------------------------------------------------------------

Func ColorLeft ()

Do

   $pixel = PixelGetColor(804,586)

   Sleep(100)

Until Not $pixel = 0xFF8800

EndFunc

------------------------------------------------------------------------

So to my understanding this means  when my $pixel is NOT the color 0xFF8800 anymore it will end the Do loop and function, correct?

I tried it, but the script doesn't react either. What am i doing wrong? Seems like the same problem as my Example 1 maybe? But still, while it seemed so logic and simple...:(

 

After this, i tried comparing $pixel to another variable and that went totally wrong

Example 3 :

------------------------------------------------------------------------

Func ColorLeft ()

Local $firstpixel = PixelGetColor(804,586)

Do

   $pixel = PixelGetColor(804,586)

   Sleep(100)

Until $pixel <> $firstpixel

------------------------------------------------------------------------

Now $firstpixel grabs the same color as $pixel is gonna do right? And that only one time cause it is out of the Do loop right? Then at a certain point $pixel 's color code is gonna change when there is another color on that pixel coordinate, correct? Then it will match itself with $firstpixel and if it is not the same then it will end the Do loop? But this doesn't work how i want it  to. i can see the change happening on my screen but the script doesn't react. Same problem perhaps as Example 1 and 2? Or maybe i am comprehending the way this script works wrong?

Well those are my problems and questions. I can tell you that i'm real confused, so if someone could explain and clarify stuff up for me that would be great!

Thanks alot in advance,

 

Link to comment
Share on other sites

Hello AutoBert,

Thanks for replying!

So there is nothing wrong with the scripts? Then why do i keep having these problems?  Is it because it failed to see a pixel change because of the resolution?

 

Link to comment
Share on other sites

Hello JohnOne, Mikell,

Thank you for your replies!

It has cleared up my confusion!

@mikell Because i'm not that experienced and still fairly new to my opinion, this is all just a learning process for me. The Help File still provides me a lot of info on figuring out what everything does and where and how to use it.  So i don't really have a big script where i dropped this in.
It's just a While/Wend loop with a few MouseMove actions after my PixelGetColor function completes itself. :)

So i've been trying out new coordinates on PixelGetColor and with a handle as @JohnOne said it would be probable that it's not the Pixel i'm thinking. I have also looked for a game, thinking there would be clear pixel changes on almost any spot, so i took PinBall3D.
Now i let my mouse move to a spot on PinBall3D with MouseMove(998,451,1) with AutoIt Info Window on to provide me the correct color so i can add it in the script or just to check it out and now this works 90% of the time.
But it still completes instantaneously once in a while, but at least now i know why. At coordinate location (998,451) in the exact spot as before, it sometimes provides me a different color than when i last checked it with AutoIt Info Window. what is up with that?
I'm on the exact same screen though and nothing has changed on it.

(keep in mind that i ran PinBall3D in windowed mode 1024x768)
 

Edited by J0t4r0
Link to comment
Share on other sites

  • Developers
1 hour ago, J0t4r0 said:

move to a spot on PinBall3D with

@J0t4r0,

Welcome to the AutoIt forum. :)

Unfortunately you appear to have missed the Forum rules on your way in. (there is also a link link in my signature) 
Please read them now particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

See you soon with a legitimate question I hope. :)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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