Jump to content

Advanced Pixel Search Library


FastFrench
 Share

What do you think of this library ?  

35 members have voted

  1. 1. What do you think about FastFind ?

    • It's really great, I can't imagine doing a script without it
    • It's of some use for me in my current scripts
    • I could use it some day
    • Looks nice, but of no use for me
    • I've tried it, but it doesnt fit my needs
    • Sounds good on the paper, but can't make it work (bug or too difficult to use it)
  2. 2. Have you tried it ?

    • Yes, I'm using it right now
    • Somewhat, I've done some testing, will surely use it later
    • I've downloaded it and just played a little with packaged demo scripts
    • I've downloaded it, but not tried it so far
    • Not downloaded it so far, but I probably will some day
    • It's of no interested for me.
  3. 3. What is missing or should be improved ?

    • It has all the features I may need about Pixels Handling
    • OK it's pretty fast, but couldn't it be faster ?
    • Too hard to use it, could you simplify usage ?
    • Some additional features would be nice to have (please explain in a message)
    • It really lacks some decent documentation (I still hope to find someone to help on that)
    • Some critical features are missing, can't use it (please explain in a message)
    • I found some minor bugs (please explain in a message)
    • I've found some serious bugs (please explain in a message)
    • I've never tried it so far, can't tell
    • It would be nice if you could provide easy access to the associated tool - FFShowPixel
    • I would like to use it other languages. Could you provide wrappers ? (please explain in a message)


Recommended Posts

Is there a fast way to use the opposite of FFkeepColor? To change the find pixels to a new color and keep the remaining pixels the same?

I need a way to quickly filter the screen by color by just changing the searched pixel to red or any color that I specify while the rest of the pixels remain intact so I can essentially test different shade variation and visually identify the results.

Link to comment
Share on other sites

I think your trying to debug the hard way. If you need to just visualize the found pixels, try using the $FFDefautDebugMode to 0x04.

Otherwise you need to get a list of the found colors, and set the pixel colors manually. There was an example on page 19.

Link to comment
Share on other sites

Regarding SizeSearch, it seems restricted to only using perfect square areas because of using the same length and width.
I'm looking to change that so I can use non equilateral rectangles (different width and length).

How could this be done?

Edited by DigiBox
Link to comment
Share on other sites

@Devilz_2

I just thought of something that might work for you.

You probably want to duplicate your base snapshot twice. One for the colors you want to keep, and the second to redraw the changes onto.

Duplicate Snapshot 1) Might be tedious or clunky to do it this way, but you could use FFKeepColor for the specified pixels you want to keep.

Next we are going to modify this snapshot with the kept colors and all black pixels of the discarded colors.

I'm assuming here that FFSetPixel uses the format 0xAARRGGBB, but you could try and set all the black pixels to an alpha of zero, essentially transparent. Use a loop.

So that the black pixels might / should look like is 0xFF000000, and we need to change all of them to 0x00000000.

Duplicate Snapshot 2) Now that we have them changed, use FFKeepChanges($dSS2, $dSS1). No shade variation.

$dSS2 is the base duplicate of the original snapshot, which will be overwritten from the function call.

$dSS1 is the colors you kept and modified all the black pixels from.

In theory, since it will redraw the transparent pixels onto the existing ones, it should keep the same shade or alpha transparency of the entire snapshot, while overwriting only the kept colors.

I don't have the time right now to write a test script.

Edit: This probably won't work because BMP does not support transparency. So you may end up with all black pixels. I don't know how KeepChanges performs the operation.

However, if the above does not work we might be able to manually stitch them together via BitOR.

 

@DigiBox

I don't think we can change the Square from SizeSearch, because that's a hard coded function inside the FastFind.dll file. FastFrench would have to add a new function for that, and since he has been absent for multiple years now, I wouldn't count on it any time soon. This box is only the scan window. What's important that you have to use an irregular rectangle shape?

Edited by KrinnyAit
Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

hi guys i have little questions, is possible with this udf, do a path find ?? , example:

I have this graph  for earthquacke https://ibb.co/Mk2NvxV 

i have many  path ...... one is  this  https://ibb.co/GdyF8f8

is possible find a shape + color (with shape and color approximation   ) if  you look a path is 3 vertical  circle .... almost circle , and  some time is perfect circle and must match

thankz at all

Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...
  • Developers
3 minutes ago, renzonline said:

I have the same question as this partner, could someone help us to convert this function

So what happened in 2016 ...  you didn't pay enough? ;) 

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I abandoned the project at that time, now I have a bit of free time and I always had that hard way of converging that.

I read that post in full, but I can't make the change from pixelsearch to FFGETPIXEL work, my English doesn't help me

 

teset1.png

Link to comment
Share on other sites

  • 1 month later...

Literally created this account just to post this.

First of all, I LOVE FastFind. Is it perfect? No. But what is? The important thing is that... it's fast. At least for my use case, it's multiple orders of magnitude faster than using the built-in autoit pixel functions.

However, the one thing that was a huge pain is TRACER.TXT -- I searched the forums (and Google) high and low, and the best advice I found was earlier in this thread -- to just use FileDelete to remove it at the end of the script. Unfortunately, it seems that the script maintains a file lock on it and I could neither delete it at the end NOR the beginning of the script. I tried setting a blank TRACER.TXT to read-only, which succeeded in stopping the script from writing to it by immediately crashing the script. Finally, I opened up the .au3 file and pretty much instantly determined the problem: the script defines a default debug level, and constantly sets the debug level to that default irrespective of calls to FFSetDebugMode. I'm sure that there's a way to edit it to properly respect those calls, but frankly I don't need or want any debugging from FastFind, so the easiest solution for anyone with the same problem is:

1) Open FastFind.au3

2) Fast, find "global $FFDefautDebugMode = 0xE7 ; Si below to the meaning of this value. To remove all debug features (file traces, graphical feedback..., use 0 here)" -- currently, it is on line 87, but that might change if an updated version comes out or you have modified your file already.

3) Set that to the value that you wish: 0, if you want no debugging, as per the comment, or any of the other valid debugging levels.

Hopefully this helps anyone else with the same problem in the future.

Link to comment
Share on other sites

Sorry, but I couldn't find a way to edit my previous post. Just thought I'd throw a code snippet out for anyone who might make use of it.

I primarily use FF to detect if regions of the window have changed, and use the following function to compare a pre-calculated FFComputeMeanValues to the current screen:

Func CheckMCMatch($MC,$coords,$log)
    TakeSnapShot($coords,1)
    $CMC=FFComputeMeanValues(1)
    If $MC[0]==$CMC[0] And $MC[1]==$CMC[1] And $MC[2]==$CMC[2] Then
If $log==True Then ConsoleWrite("CheckMCMatch success "&$MC[0]&","&$MC[1]&","&$MC[2]&" vs "&$CMC[0]&","&$CMC[1]&","&$CMC[2]&@LF)
        Return True
    Else
If $log==True Then ConsoleWrite("CheckMCMatch failed "&$MC[0]&","&$MC[1]&","&$MC[2]&" vs "&$CMC[0]&","&$CMC[1]&","&$CMC[2]&@LF)
        Return False
    EndIf
EndFunc

(the arguments are: the FFComputeMeanValues array you're comparing against, the coordinate box that you're checking, and whether to output the result to the console)

However, sometimes the thing I'm checking can vary a bit in terms of the exact pixel values, so I use this to allow you to define an acceptable range of difference in each color channel:

Func CheckMCFuzzy($MC,$coords,$Rdiff,$Gdiff,$Bdiff,$log)
    TakeSnapShot($coords,1)
    $CMC=FFComputeMeanValues(1)
    If $MC[0]>=$CMC[0]-$Rdiff And $MC[0]<=$CMC[0]+$Rdiff And $MC[1]>=$CMC[1]-$Gdiff And $MC[1]<=$CMC[1]+$Gdiff And $MC[2]>=$CMC[2]-$Bdiff And $MC[2]<=$CMC[2]+$Bdiff Then
If $log==True Then ConsoleWrite("CheckMCMatch success "&$MC[0]&","&$MC[1]&","&$MC[2]&" vs "&$CMC[0]&","&$CMC[1]&","&$CMC[2]&" ("&$Rdiff&","&$Gdiff&","&$Bdiff&")"&@LF)
        Return True
    Else
If $log==True Then ConsoleWrite("CheckMCMatch failed "&$MC[0]&","&$MC[1]&","&$MC[2]&" vs "&$CMC[0]&","&$CMC[1]&","&$CMC[2]&" ("&$Rdiff&","&$Gdiff&","&$Bdiff&")"&@LF)
        Return False
    EndIf
EndFunc

(the same arguments, except with the acceptable R, G, and B channel differences inserted just in front of the log)

Usage examples:

CheckMCMatch($detectfishingMC,$detectfishing,False)
CheckMCFuzzy($detectotherfishunusedMC,$detectotherfish,50,50,50,False)

Cheers!

Link to comment
Share on other sites

  • 2 months later...

This is awesome, much better than PixelSearch.

I've only come across perhaps one bug that keeps finding FFNearestPixel outside the snapshot area specified.  If I use the code alone with ForceNewSnapshot to false then it will be correct.  If I set it to true, it will be outside.  If I use it in my script which also has FFNearestPixel earlier in the code, no matter if I use true or false it gives me a X,Y result outside the snapshot window.  

Edited by vulcan4d
Link to comment
Share on other sites

  • 3 months later...

Hi Folks. I need some help. 🤕
Probably an OSI Layer 8 problem, but I can't find the solution.

I try to snapshot a dropdown menue in a drawing Software on Screen 2 (Pen Display).
(After that I want to figure out if Checkboxes in the dropdown are checked or not, but that's not relevant, as I fail early.)
It's happening on WIN 10

If I do 

; settings
        AutoItSetOption ( "MouseCoordMode", 0 )      
; activate window
        local $hWnd = WinActive( $sCSPWinTitle )
        If $hWnd == 0 Then
            WinActivate( $sCSPWinTitle )
            $hWnd = HOK_ReactToWin( $sCSPWinTitle )
            WinSetState($hWnd, "", @SW_MAXIMIZE )
        EndIf
; Open Dropdown
        MouseClick("Left",$iFiltButtonX,$iFiltButtonY)
; FastFind
        FFSnapShot ( )
        FFSaveBMP ( "BaseA")

I get a screenshot of Screen 1 saved as BaseA.bmp

I tried this as well
 

; settings
        AutoItSetOption ( "MouseCoordMode", 0 )      
; activate window
        local $hWnd = WinActive( $sCSPWinTitle )
        If $hWnd == 0 Then
            WinActivate( $sCSPWinTitle )
            $hWnd = HOK_ReactToWin( $sCSPWinTitle )
            WinSetState($hWnd, "", @SW_MAXIMIZE )
        EndIf
        
        
;Difference to solution 1 => set Window Handler for FastFind        
        FFSetWnd ( $hWnd )        
      
; Open Dropdown
        MouseClick("Left",$iFiltButtonX,$iFiltButtonY)
; FastFind
        FFSnapShot ( )
        FFSaveBMP ( "BaseA")

But this time BaseA.bmp showed the correct screen (the drawing software is full screen on screen 2), but it doesn't show the drop down. Probably it has a different window handle, or the window handle dosn't take care of children.

So back to attempt one: How can I screenshot Screen 2?

Link to comment
Share on other sites

I found a workarround for my problem one post above, by adressing the dropdown as window via its class.

If you run into something similar:

  • Open Autoit Info
  • Uncheck "Options"->"Freeze"
  • Copy the class and do soemthing like this
Const $sClassWinFilterDD = "[class:742DEA58-ED6B-4402-BC11-20DFC6D08040-6571DDC4-B3AA-45e4-9D35-57C0C1E90AD5]" ;Class of Dropdwon of Filters

; settings
        AutoItSetOption ( "MouseCoordMode", 0 )      
; activate window
        local $hWnd = WinActive( $sCSPWinTitle )
        If $hWnd == 0 Then
            WinActivate( $sCSPWinTitle )
            $hWnd = HOK_ReactToWin( $sCSPWinTitle )
            WinSetState($hWnd, "", @SW_MAXIMIZE )
        EndIf
        
;The magic to screenshot the Dorpdown Window on Screen 2 
         $hWnd = WinWaitActive( $sClassWinFilterDD )
         FFSetWnd ( $hWnd )      
      
; Open Dropdown
        MouseClick("Left",$iFiltButtonX,$iFiltButtonY)
; FastFind
        FFSnapShot ( )
        FFSaveBMP ( "BaseA")

However: This is solving my current problem, but I can imagine that there will still be occasions where one needs to capture the second screen. So the orignal quesions remains: How to use the second screen in FFSnapShot () ?

Link to comment
Share on other sites

  • 1 month later...

I don't know if there is alway someone here to help people.

I have a big problem since windows 10, all Chrome_windgetWin_1 windows got black screen when snapshot them, i don't know why. Or maybe i mistaken the problem but i got stuck in my search of solutions.

I alreay had this probleme in 2019 but none helped me.  here: https://www.autoitscript.com/forum/topic/126430-advanced-pixel-search-library/?do=findComment&comment=1415361

 

 

Link to comment
Share on other sites

@yolopota Many people are willing to help but frequently you get no help if you do not

  • Show the code that is breaking
  • Show a small script to reproduce so people can copy/paste and directly test themselves if it shows same behaviour
  • Can you reproduce on multiple machines (laptop and desktop can make a difference with graphic processing units and how snapshots are taken)
  • Did you try other snapshot mechanisms to create a bitmap
    • Autoit functions as you can find in help to create a bitmap
    • bitblt: 
    •  
  • Proof its not a game you are automating
Link to comment
Share on other sites

  • 1 month later...

Hello,

I using function FFLocalizeChanges to detect the change on a region in camera.

If using on one camera screen ($handle_1 only), it's ok, but if I using it in two different camera screen ($handle_1 and $handle_2) it always return error 1 when the image change or not change.

Is FFLocalizeChanges can't working in different handle or maybe I do something wrong? Thanks for all helping.

#include <Array.au3>
#include <FastFind.au3>

FFSetWnd($handle_1)
FFCapture(34, 303, 46, 30, 1)

FFSetWnd($handle_2)
FFCapture(34, 303, 46, 30, 2)

$change = FFLocalizeChanges(1, 2)

ConsoleWrite(@error & @CRLF)

_ArrayDisplay($change)

 

Link to comment
Share on other sites

  • 1 month later...
On 2/27/2021 at 2:41 PM, zkenjiz said:

Hello,

I using function FFLocalizeChanges to detect the change on a region in camera.

If using on one camera screen ($handle_1 only), it's ok, but if I using it in two different camera screen ($handle_1 and $handle_2) it always return error 1 when the image change or not change.

Is FFLocalizeChanges can't working in different handle or maybe I do something wrong? Thanks for all helping.

#include <Array.au3>
#include <FastFind.au3>

FFSetWnd($handle_1)
FFCapture(34, 303, 46, 30, 1)

FFSetWnd($handle_2)
FFCapture(34, 303, 46, 30, 2)

$change = FFLocalizeChanges(1, 2)

ConsoleWrite(@error & @CRLF)

_ArrayDisplay($change)

 

Exactly, only true in same handle, with same location (left, top, right, buttom). 

Link to comment
Share on other sites

  • 1 month later...

 

The terrible day finally came, FF 2.1 didn't run, FF 2.2 started showing some errors. The first that I discovered was _FFColorCount with the shader returning the wrong value. What do we have to do to get him back?

Edited by Jos
Please use standard fonts!
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...