Jump to content

How to Store dynamic variables in array to use later ?


Recommended Posts

Hi,

I am new to autoit and I am trying some new things so sorry if this is an easy question.

I want to do the following:

1. search an area for the color change to 0xEEEDEE and I did this the following:

$Pixel = PixelSearch(424, 489, 774, 601, 0xEEEDEE,0,0)

2. the color may appear more than once so I want to store the mouse position in an array. $Pixel is an array which will store the x and y positions but I want to loop through it.

3. the first color change position will be stored in the first array element and so on ...

4. I want to read the values and move the mouse according to it.

How can I achieve this ? Is there a better way than pixelsearch ?

Thank you so much

Edited by momo1984
Link to comment
Share on other sites

I haven't tried this in code. But according to my reading of PixedlSearch() it returns a 2 element array with x,y of the found pixel. It would seem a simple count of hits would increment the destination array index after you copy those coordiinates into the destination array. Since PixelSearch() expects a rectangle you may need to use PixelGetColor() once you have a hit on a line, to finish the search on that line. Then adjust the top left corner of the rectangle and call PixelSearch() again.

A simple For loop calling PixelGetColor() should finish out the line where the last x hit plus one would be the initial value of the loop counter if you are searching left to right and top to bottom. Pretty vanilla.

Edited by MilesAhead
Link to comment
Share on other sites

I haven't tried this in code. But according to my reading of PixedlSearch() it returns a 2 element array with x,y of the found pixel. It would seem a simple count of hits would increment the destination array index after you copy those coordiinates into the destination array. Since PixelSearch() expects a rectangle you may need to use PixelGetColor() once you have a hit on a line, to finish the search on that line. Then adjust the top left corner of the rectangle and call PixelSearch() again.

A simple For loop calling PixelGetColor() should finish out the line where the last x hit plus one would be the initial value of the loop counter if you are searching left to right and top to bottom. Pretty vanilla.

thank you for the reply,

I will try to understand your point more as it seems a little confusing after a first look into it :-)

Link to comment
Share on other sites

PixelSearch() searches a rectangle. But it only returns the first hit. So if you have a rectangle symbolized by '+' for pixel with '/' a matching pixel like this

***********

***********

******/

You have to figure out the position of the hit in the rectangle to see if you need to check the rest of the pixels in that row using PixelGetColor(). If the hit is he last pixel in the row like this

***********

***********

**********/

then you only have to save the data and call PixelSearch() with the first pixel in the next row as the new starting position. Otherwise you'll be chopping off a section of the original rectangle. Not what you want.

Edited by MilesAhead
Link to comment
Share on other sites

hmm sorry but am still confused :-)

If I do the pixel search it will return a result like (200,300) where $Pixel[0] = 200 and $Pixel[1] = 300

now I need to insert these values in an array , should I define a 2D array ?

I just noticed this library. It looks interesting

It comes with both 32 and 64 bit Dlls a help file and other stuff. It's meant to be used with AutoIt3

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