AutoHotkey Community

It is currently May 27th, 2012, 1:24 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Pixel Matrix Search
PostPosted: June 22nd, 2005, 6:48 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
I finally completed this script. It is like ImageSearch, but it doesn't require an image file and works better for me. It has 2 functions, GetMatrix & FindMatrix.
There is an example in the script to find a 3x3 matrix.

Note: For faster searching, make sure the first pixel of matrix is not abundant on the screen.

Script

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 22nd, 2005, 9:37 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Thanks for sharing this. I know ImageSearch can be cumbersome to use, and PixelSearch can often be too crude. Your solution is a great compromise.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2005, 8:09 am 
Hi Rajat :D
won't the following line (taken from your script) restrict it to a 800x600 screen resolution :?:
Quote:
Result := FindMatrix(1,800,1,600,3,Matrix)
Thx for sharing it. 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2005, 10:11 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
Quote:
won't the following line (taken from your script) restrict it to a 800x600 screen resolution

yes it will. but its not hard-coded in the function, its just part of the example. i cud've restricted it to just the systray too.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 5th, 2006, 3:25 pm 
Offline

Joined: October 10th, 2005, 10:44 am
Posts: 299
Location: Germany
I might be dumb, but I don't quite understand what this is for.
If I execute the script and press F4, it returns me two values (coordinates?) - but what to do with these?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 5th, 2006, 3:55 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
It searches for an 3x3 pixel color matrix on your screen. If you have pressed F4 with your mouse somewhere inside the 800x600 area of your screen. You should get back that position.
What the code does: It gets the matrix under your mouse pointer and starts to search for that matrix on your screen (the 800x600 upper left part). If it finds it it reports back the coordinates.
As Rajat said, it is faster then ImageSearch and it doesn't require an image.
You can use it to find a pattern (the 3x3 matix) on the screen if it unique. E.g. an icon, a picture or an item in a game.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 5th, 2006, 4:07 pm 
Offline

Joined: October 10th, 2005, 10:44 am
Posts: 299
Location: Germany
Oh, I see - thanks for the clarification!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2006, 2:24 pm 
its i fine script, but how can make it that my cursor jumps back
on that matrix
it shows me a little red dot and the scipt ends


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2006, 10:01 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
just do a MouseMove at the received coordinates

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2006, 10:02 pm 
hi,
i'm very impressed with this pixel matrix thing, but i'm hoping someone can help me out

once i find my 9 by 9 matrix, what code should i input for me to save it so i can refer to it later. i would like to save a bunch of 9 by 9 matrix's and just name them matrix1.bmp and matrix2.bmp and so on, so i can search the screen for the same matrix and do the required mouseclick.

also, if i increase the matrix size to say a 4x4, the image comparison would be better right?, but would it bog down the script too much?

Code:
GetMatrix(StartX,StartY,Dimension)
{
   Loop, %Dimension%
   {
      Loop, %Dimension%
      {
         PixelGetColor, Pix, %StartX%, %StartY%
         Matrix = %Matrix%|%Pix%
         StartX ++
      }
      
      StartY ++
      StartX -= %Dimension%
   }
   StringTrimLeft, Matrix, Matrix, 1
   Return %Matrix%
}


anyhelp is much appricated


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2006, 1:11 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
with this script you can save the recd matrix in the script itself and it doesn't need a separate file. if you want to save .bmp files then u better use the imagesearch command instead of this script, as the recd matrix from this script is plain text and not an image.

the image finding would definitely be better with a bigger matrix. and just take care of the first pixel thing and you should be fine.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2006, 6:05 am 
thanks for the quick reply.

i have tried using image search, but so far no luck

my problem is i get a screen shot, crop out the selected image i want to search for and try it out. it will find the image by itself, meaning alone.

but it won't find the image in the screen shot without it being cropped. that is why i think i need to go the matrix way.

how do i save the matrix file, can i save the text of the matrix, and use it later?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2006, 3:41 pm 
j88chan wrote:
how do i save the matrix file, can i save the text of the matrix, and use it later?


yes you can, that's the point!... just like you can define a control name for most apps in scripts, for apps which don't have recognisable controls can be automated this way and the pixel matrix for its control can be retrieved from the first function and saved in the script... later on the second function can find it and do button presses etc.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 20th, 2006, 5:00 pm 
Offline

Joined: July 11th, 2006, 9:47 pm
Posts: 2
ok, i feel stupid, i've been trying this for a few hrs

please help me

i want to use the script you wrote. but instead of using the getmatrix sub function, i want to just define my matrix. i have tied some things, but i'm guessing it has to do with inputing the 9 pixels into a 3 by 3 array. i just can't do it, i'm dumb. this is my matrix in text.


0x000000|0x205D47|0x215E48|0x000000|0x1B5640|0x1C5741|0x000000|0x777777|0x18513C

can someone give me the 2-3 lines of code that replaces "getmatrix" for the matrix above. From there i should be able to continue the rest of the program

thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 20th, 2006, 7:44 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
assuming that the matrix you posted is available on your screen, you can do this:

matrix = {your matrix}
Result := FindMatrix(1,A_ScreenWidth,1,A_ScreenHeight,9,matrix)
StringSplit, Result, Result, %A_Space%

now result1 & result2 contain the x & y coords of your target.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon, Yahoo [Bot] and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group