Jump to content

PixelSearch issues


Recommended Posts

Greetings AutoIT forum,

1)

I have a simple image file opened at the top left corner of my screen.

The actual image is 350x350px and with the script moved to x,y 0 0.

The image is all white with one single black dot.

I took a Full Print-Screen and measured the distance to the dot from the screen edges in Photoshop - x,y 245 259.

When running the script using PixelSearch( 42, 82, 350, 350, 0x000000 ), it says the pixel is found at 246 262 ?!

(The x,y 42 82 is just to "jump in" and skip the Image Viewer toolbar etc)

I can buy the x: 246 (depending on if x is where the pixel is found, or if the next pixel counts), but the y 262???

2)

Regarding function reference: How exactly does the "search direction" work and how do I change it (there is no argument for it) ?

3)

According to function reference: "color | Colour value of pixel to find (in decimal or hex)."

How come the example below uses "0xFF0000" and not just "FF0000" ? Perhaps best to use decimal (255 0 0) ?

I have read and elaborated with the docs for the PixelSearch function as well as searched for simple example scripts, without too great success.

Thanks in advance.

Edited by Xibalba
Link to comment
Share on other sites

1)

Please add screenshot, this help a little to create a code :blink:

2)

i saw that is checking each pixel from left up corner to right up corner (step by +1 pixel)

No, i tried to change direction a little bit, but fail ;\ (I am not perfect :P)

3)

idk, but where is the problem? ;)

This world is crazy

Link to comment
Share on other sites

1. What is the question here? Why y is 262? Only you know that, we don't know how your screen looked when you got that.

2. The helpfile tells you how to do it.

The search direction varies as follows:

Left-to-Right - left < right

Right-to-Left - right < left

Top-to-Bottom - top < bottom

Bottom-to-Top - bottom < top

So if you want to search from right to left just put the left coordinate in the right parameter and vice versa.

3. Because you write hex as 0xFF0000, writing just FF0000 means nothing.

Perhaps best to use decimal?

That doesn't matter. Decimal and Hex is the same thing in AutoIt, and you can freely interchange them with each other.

Link to comment
Share on other sites

I figured out my questions by further testing. I added one pixel to my MsgBox output ($coord[0]+1), ($coord[1]+1) to get true visual distance (easy measurable in ps).

Thanks for an explanation of search direction, although I find the docs rather confusing, what about replacing:

Bottom-to-Top - bottom < top

with

Bottom-to-Top - bottom < top (If the bottom parameter < top parameter, Bottom-to-Top search direction is used.)

...Or just add a another example below, searching Bottom-to-Top and Right-to-Left?

Anyway, thanks for all the replies.

Edited by Xibalba
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...