JimIn1985

Function is always returning 'True', no matter what.

8 posts in this topic

I've been trying to fix this all day but I can't even find the problem. I'm trying to get the position and color of a specific pixel, then find out if the pixel is still the same color after a while. I'm going absolutely crazy, I've got other very similar parts of code that work fine in the same script, but for some reason this specific part always returns true. Does this also return true no matter what for you guys or is it just me?

$test = MouseGetPos()
sleep(5000) ; I move my mouse away during this time to avoid its interference with the pixel color
$testcolor = PixelGetColor($test[0],$test[1])
sleep(10000)
If $testcolor == PixelGetColor($test[0],$test[1]) Then
    msgbox(1, "title", "the value is true")
EndIf

 

Share this post


Link to post
Share on other sites



It must be true as you are asking both times the same coord. But to automate a app with one of the ugly func's like PixelGetColor is normaly not needed. Most serious apps can be automated by native AutoIt func's or already written UDF's. May be it takes a bit longer to prog, but it runs on same OS-Arch on every pc. So please name the app to get better help.

Share this post


Link to post
Share on other sites

Sorry, I should have mentioned that during this part of the code:

sleep(10000)

I make sure that the specific pixel has changed color (I went as far as making my whole screen blue, recorded the pixel color, then made my whole screen red and it still returned true) , I have no idea what I'm doing wrong.

Share this post


Link to post
Share on other sites
7 minutes ago, JimIn1985 said:

I make sure that the specific pixel has changed color

No, you are assigning with 

$test = MouseGetPos()

the coords to array $test. And both times you are using this coords.

Share this post


Link to post
Share on other sites

Yes, I'm using the same co-ordinates, but the pixel in those co-ordinates is definitely changing. I've tries a single equals sign as well, still returns true every time. I'm sure I'm missing something super simple here...

Share this post


Link to post
Share on other sites

Well, I'm an idiot. I have another value with a similar name in my script, I mixed them up... Sorry for wasting your time, I was sure that it was a problem with this snippet of code.

Share this post


Link to post
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