Jump to content

Pixel Reading


 Share

Recommended Posts

Something seems to be wrong with my code here:

Sleep (5000)
$i = 0

While $i = 0
Sleep (8000)
If PixelGetColor (880, 200) = 0x507391 And PixelGetColor (795, 362) = 0xC7E2E2 Then MouseClick (795, 362, 10)
If PixelGetColor (880, 200) = 0x782F3A And PixelGetColor (795, 441) = 0xC7E2E2 Then MouseClick (795, 441, 10)
If PixelGetColor (880, 200) = 0x782F3A And PixelGetColor (795, 491) = 0xC7E2E2 Then MouseClick (795, 491, 10)
If PixelGetColor (880, 200) = 0x782F3A And PixelGetColor (795, 427) = 0xC7E2E2 Then MouseClick (795, 427, 10)
WEnd

To create some simple loop I just made $i = 0 forever because I want this to keep looping forever. Then I just stop the process by going to Task Manager and ending the process.

When I'm running this, the Mouse just seems to go to the top of the screen, click, and move right, then wait 8 seconds, then move left and click in the exact same spot, then move right, etc. I'm not sure why.

Would there be something wrong with me use 'And' like that? Or is PixelGetColor not accurate enough to read pixel color pixel by pixel? I have double checked all the values and they all work.

Link to comment
Share on other sites

Hi there!

Welcome!

Have you tried to add a small sleep in?

Also add some error checking, like Consolewrite for each case.

Also try adding parenthesis for each condition.

i.e

If ($condition = True) And ($condition2 = True) Then ....

Cheers,

Brett

Edited by BrettF
Link to comment
Share on other sites

Hi there!

Welcome!

Have you tried to add a small sleep in?

Also add some error checking, like Consolewrite for each case.

Also try adding parenthesis for each condition.

i.e

If ($condition = True) And ($condition2 = True) Then ....

Cheers,

Brett

The sleep in gave the same results.

I don't understand Consolewrite. What do STDOUT and STDERR mean? I tried searching on google, but it didn't really explain on how it relates to anything.

I tried the paranthesis as well, and the same results.

This is my current code:

Sleep(5000)

While 1
    Sleep(8000)
    If (PixelGetColor(880, 200) = 0x507391) And (PixelGetColor(795, 362) = 0xC7E2E2) Then MouseClick(795, 362, 10)
    Sleep(250)
    If (PixelGetColor(880, 200) = 0x782F3A)And (PixelGetColor(795, 441) = 0xC7E2E2) Then MouseClick(795, 441, 10)
    Sleep(250)
    If (PixelGetColor(880, 200) = 0x782F3A) And (PixelGetColor(795, 491) = 0xC7E2E2) Then MouseClick(795, 491, 10)
    Sleep(250)
    If (PixelGetColor(880, 200) = 0x782F3A) And (PixelGetColor(795, 427) = 0xC7E2E2) Then MouseClick(795, 427, 10)
WEnd
Link to comment
Share on other sites

Well this is weird. I fixed it by adding "Left", right after MouseClick and before my coordinates. Who would've known that that could screw up the script that badly.

The funny part is that I had it in the beginning, then I forgot about it when I was rewriting the code. Here's the final code that works:

Sleep(5000)

While 1
    Sleep(8000)
    If (PixelGetColor(880, 200) = 0x507391) And (PixelGetColor(795, 362) = 0xC7E2E2) Then MouseClick("Left", 795, 362, 10)
    If (PixelGetColor(880, 200) = 0x782F3A)And (PixelGetColor(795, 441) = 0xC7E2E2) Then MouseClick("Left", 795, 441, 10)
    If (PixelGetColor(880, 200) = 0x782F3A) And (PixelGetColor(795, 491) = 0xC7E2E2) Then MouseClick("Left", 795, 491, 10)
    If (PixelGetColor(880, 200) = 0x782F3A) And (PixelGetColor(795, 427) = 0xC7E2E2) Then MouseClick("Left", 795, 427, 10)
WEnd

Thanks for the help!

Link to comment
Share on other sites

Just to note after the remark about the parenthesis, what he was doing in right to a extent, he obeyed the rule of operation scince the equals comes before the AND. However the one thing you were missing was the "button" to click: "left", "right", "middle", "main", "menu", "primary", "secondary".

Is there a rule in the UDF to allow for the parenthesis to explictly say what your doing or is there not

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Link to comment
Share on other sites

Do pixel colors differ on every person's monitor? I gave this program to a friend, and ended up having to change all the color values by him sending me .bmp images of the colors I needed to see. We were both using the same browser, IE8.

If that's true, then the program I created here would only work on my computer?

Link to comment
Share on other sites

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