AutoHotkey Community

It is currently May 26th, 2012, 3:09 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 30 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: July 21st, 2006, 2:30 am 
Offline

Joined: July 11th, 2006, 9:47 pm
Posts: 2
thanks alot, you've got it working for me, now for some long programing

you rock


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2006, 4:24 pm 
Offline

Joined: July 18th, 2006, 12:18 pm
Posts: 403
Ok im very confused still

Ok i hit f4 i get the cords of the matrix now if i wana find the matrix that i just got the cords for who do i serach for them in my script

thanks very much


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2006, 6:34 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
Please read the topics on PixelSearch and ImageSearch in ahk help fully (yes, do it) and come back to this topic... i'm sure that'll help you understand the functions.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2006, 6:56 pm 
Offline

Joined: July 18th, 2006, 12:18 pm
Posts: 403
I know how to use them i use them all the time but i mean when it returns the crods after you hit f4 how do i make it search for that matrix in one of my scripts, because on 1st post you only one script that gets the matrix now where do i get the one the i add into my script to make it sreach for my matrix.

thanks and also if u post it please tell me how to use like where to enter the cords thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2006, 8:11 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
there's a function FindMatrix in this script that finds the location of your provided matrix.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2006, 8:48 pm 
Offline

Joined: July 18th, 2006, 12:18 pm
Posts: 403
ok cool so i edit that part of ouf scrip and add it to my script then i put those cords in there then done ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2006, 9:39 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
yes if u've extracted the matrix then u'll probably not need the GetMAtrix... but its a a better practice to keep your functions in separate files and #include whichever reqd.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2006, 1:36 pm 
Offline

Joined: September 20th, 2005, 9:23 pm
Posts: 16
Thanks for these functions Rajat. :)

The GetMatrix() function was very useful for me. I made a change so that it is able to search rectangular areas as well and wanted to share it in case anyone has a use for it.

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


Note: I do not think this is compatable with the FindMatrix() function, but it was useful to me on its own.

_________________
-Lufia


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2006, 3:20 am 
Offline

Joined: July 18th, 2006, 12:18 pm
Posts: 403
How can i input the findmatrix function into my script so it finds the matrix while user are running the script then right after its got the matrix at mouse position. it will keep on searching untill that matrix is not avalible anymore?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2006, 2:10 am 
Offline

Joined: February 24th, 2006, 12:56 am
Posts: 172
very nice, thanks for sharing


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2007, 11:30 pm 
Offline

Joined: August 20th, 2007, 6:57 pm
Posts: 185
Thanks for sharing I got it working but I cant get it to work in any application can you offer any help? it will find say Mozilla firefox on my desktop but if I try it with windows picture and fax viewer it say's 0,0 or solitare microsoft office internet explorer browser etc.
Thanks in Advance


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Optimization
PostPosted: March 4th, 2009, 4:29 pm 
Offline

Joined: March 4th, 2009, 4:15 pm
Posts: 7
Great function, thanks for posting.

I'd identified an error (optimization really) that was causing some issues when the first pixel was not unique on the screen. After the 2 for loops that check the individual pixels, I updated StartX to the last X value returned by PixelSearch (plus one so it increments the loop).

With the original implementation I found PixelSearch was repeatedly returning the same pixel until the increment eventually caught up; which could be very wasteful in some cases :P.

For some people who are having trouble getting this to work on rectangular areas try the change below as well; I had one strange case where the function returned false negatives because the outer loop (length) was ending for some reason before the "line search" loop found the correct pixel.

Code:
FindMatrix(ScanStartX,ScanEndX,ScanStartY,ScanEndY,Dimension,Matrix)
{
   StringSplit, Pix, Matrix, |
   Length := ScanEndY - ScanStartY
   pX = 0
   pY = 0
   
   ;loop for per line of screenY
   Loop, %Length%
   {
      StartX = %ScanStartX%
      EndX = %ScanEndX%

      StartY := ScanStartY + A_Index - 1
      EndY := ScanStartY + A_Index - 1
   
      ;loop for searching inside a line
      Loop
      {
         count = 0
         MatchFound = 1
         
         ;change variance and 'Fast' if not suited
         PixelSearch, pX, pY, %StartX%, %StartY%, %EndX%, %EndY%, %Pix1%, 0, Fast
         IfNotEqual, ERRORLEVEL, 0, Break
         sX = %pX%
         sY = %pY%
         
         ;loop for matching
         Loop, %Dimension%
         {
            Loop, %Dimension%
            {
               Count ++
               PixelGetColor, CurrPix, %pX%, %pY%
               IfNotEqual, Pix%Count%, %CurrPix%
                  MatchFound = 0
               
               IfEqual, MatchFound, 0, Break
               pX ++
            }
            IfEqual, MatchFound, 0, Break
            pY ++
            pX -= %Dimension%
         }
         
         ;match found!
         IfEqual, MatchFound, 1
         {
            Result = %sX% %sY%
            Return Result
         }
         
         StartX := px + 1
         
         DiffX := EndX - StartX
         IfLess, DiffX, %Dimension%, Break
      }
      StartY ++
      EndY ++
   }
   Return 0
}


Also note: while I'm not posting I also made an edit to allow for a "transparent" value in the matrix, as I had a need to search for patterns rather than exact squares / rectangles.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2009, 6:29 pm 
Offline

Joined: March 4th, 2009, 6:10 pm
Posts: 1
Do I put this at the upper left hand corner of the 'section' I want to grab. Looking at the code, that seems to be the case, I just wanted to make sure.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2009, 10:03 pm 
Offline

Joined: March 4th, 2009, 4:15 pm
Posts: 7
The way the example is written, yes you put the mouse at the upper left corner of the 3x3 pixel matrix you want to "grab" (this can be modified of course; only a simple example is provided by the OP). It (basically) converts the pixels to ascii text then the find matrix will search your screen (800 x 600 as coded... but again, that's adjustable) and the location of the first "matching" pixel matrix is displayed.

I found this useful by expanding the size to be more than 3x3 pixels (that's so small you can hardly see what you're pointing at). Just remember to match the dimensions on both getmatrix and findmatrix functions.

For my uses I was looking for some particular patterns, so I trashed getmatrix and just used findmatrix.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2009, 5:17 pm 
Nice code, but why does pixelsearch/imageseach work so poorly in a game like WoW?
I just dont get consistent data back for 1 pixelgetcolor. Out of 10 pixelgetcolor's on the exact same coords, only 7/10 it returns the same value.

This code always returns 0 on a full-screen ap btw.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Uberi and 11 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