J0t4r0 Posted April 10, 2016 Share Posted April 10, 2016 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 More sharing options...
AutoBert Posted April 10, 2016 Share Posted April 10, 2016 Example run until the $pixel has color 0x855230 Example will run endless use Until Not ($pixel = 0xFF8800) to exit loop when pixel hasn't color 0xFF8800 Example runs until pixel changes his color (is different to color before looping Link to comment Share on other sites More sharing options...
J0t4r0 Posted April 10, 2016 Author Share Posted April 10, 2016 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 More sharing options...
AutoBert Posted April 10, 2016 Share Posted April 10, 2016 Example 2 is wrong, you must use: Until Not ($pixel = 0xFF8800) to exit loop when pixel hasn't color. Link to comment Share on other sites More sharing options...
JohnOne Posted April 10, 2016 Share Posted April 10, 2016 It's probable that you are not checking the pixel you think you are. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
mikell Posted April 11, 2016 Share Posted April 11, 2016 Your example #3 works nice So it's probably either a coord error as JO said, or a problem somewhere else in the script Link to comment Share on other sites More sharing options...
J0t4r0 Posted April 11, 2016 Author Share Posted April 11, 2016 (edited) 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 April 11, 2016 by J0t4r0 Link to comment Share on other sites More sharing options...
JohnOne Posted April 11, 2016 Share Posted April 11, 2016 Look in Window info tool - options - coord mode and make sure it is set to screen. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
J0t4r0 Posted April 11, 2016 Author Share Posted April 11, 2016 Hello JohnOne, Thank you, I never checked that, but it seemed to be set to Screen by default. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 11, 2016 Developers Share Posted April 11, 2016 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. 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 More sharing options...
Recommended Posts