Jump to content
Reizvoller

FastFind and the Pixel Values

Recommended Posts

Reizvoller

Hello,

I am using the addon-library of FastFind.au3  found here :

 

The script I've put together is rather simple but it's returning a value that I don't understand.

#include "FastFind.au3"
#Include <WinAPI.au3>
#RequireAdmin

WinActivate ("ABC Window")

Local $xyzWindow = WinGetHandle ("ABC Window")

Local $triangleSpot = FFSnapShot (212, 216, 214, 218, 1, $xyzWindow)

ConsoleWrite ($triangleSpot&@CR)

Local $triangleData = FFGetRawData (1)
Local $splitTriangleData = StringSplit ($triangleData, "00")

Local $iMax

If isArray ($splitTriangleData) Then
   $iMax = Ubound ($splitTriangleData)
   ConsoleWrite ($iMax)
EndIf

So here's the question...

If the area I have selected is a total of 4 pixels , why is the UBound return value 26?

I thought that maybe it was getting values for the 4 along with the surrounding pixels bordering the selected area, even still , it should provide only 16 values(or so I thought). 

I feel that there is a bit of pixel data or something that I am not fully understanding. If anyone could please provide materials on what is happening I'd really appreciate it. 

Thank you for your time!

-Reiz

PS : I used terms like "triangleSpot" and such because in the actual window there is a small triangle icon that I am trying to gain the pixel data of to then search for others like it on the page. I understand the area that I am selecting is a square/rectangle and not a triangle. 

Share this post


Link to post
Share on other sites
AutoBert
34 minutes ago, Reizvoller said:

I feel that there is a bit of pixel data or something that I am not fully understanding. If anyone could please provide materials on what is happening I'd really appreciate it. 

I think the author of the UDF will know it best by the way a rectangle 212/216 - 214/218 has 9 pixels:

Dim $iPixels=0
For $x=212 To 214
    For $y=216 To 218
        $iPixels+=1
    Next
Next
ConsoleWrite($iPixels&@CRLF)

maybe the params are not in the order the author excpected, see result:

Dim $iPixels=0
For $x=212 To 216
    For $y=214 To 218
        $iPixels+=1
    Next
Next
ConsoleWrite($iPixels&@CRLF)

 

Share this post


Link to post
Share on other sites
Reizvoller

As the author of the code hasn't been on this forum in over a year I am a little doubtful in successfully reaching out to them and getting a reply. With that being said thank you for the recount.

With a grid of 9 pixels being checked if I get a value of 25 out that would make sense as that is the wanted 9 and 16 "Edge" pixels.

I at this point am guessing it's how I am StringSplit -ing the FFGetRawData. I am right now using the "00" to delineate items but I'd ideally like to just count X number of characters and separate them into chunks that way. 

The output from $triangleData is FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00

It then is passed through the splitter looking for "00" which then should make blocks of "FFFFFF" , a total of 9 times.

$iMax gets it's value by Ubound ( $splitTriangleData) which gives me 20 according to my script but if the output above from triangleData is accurate, how can that be? Any ideas?

 

 

Share this post


Link to post
Share on other sites
AutoBert

I suggest to read the docu:

Quote

Return Value

Success:It returns a string stride with the Raw bytes of the SnapShot in 8 Hex digits (BGRA) of pixels from left to right, top to bottom ; every pixel can be accessed like this: StringMid($sStride, $pixelNo *8 +1 ,8) and you get for example 685E5B00 (blue = 68, green = 5E, red = 5B, alpha = 00).

Failure:Returns -1 and sets @ERROR

 

Remarks

This function is designed for advanced users only, as an example of how to use the GetRawData DLL function. In most cases, FFGetPixel is easier to use and fast enough.

Your script show me it's not designed for you (yet). So train your AutoIt skills and try after it again.

Edited by AutoBert

Share this post


Link to post
Share on other sites
Reizvoller

You are fantastically helpful! Thank you so much and I will be more diligent in re-reading the material in the future. Thank you for pointing out my error. 

Share this post


Link to post
Share on other sites
Reizvoller

Gut, dass ich Deutsch verstehen! lol Or at least enough to get by :)

Share this post


Link to post
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

  • Similar Content

    • Nick3399
      By Nick3399
      I have loaded FastFind into my code and it takes a snapshot and creates a BMP file from it. 
      My issue is now I want to imagesearch from that BMP file (or snapshot memory) and look for a specific image from that image and get the coordinates from that. 
      I have looked at all the documentation but I cannot find anything to assist me.
       
      Does anyone have any idea?
    • nooneclose
      By nooneclose
      My program has to first search for names in Column D that do not match up with column C. I got that search to work using arrays. It was slow and I could not figure out how to delete them so I just manually put coded the names that do not belong. I found their cell location but I do not know how to store that location and delete it.
      This is what I have so far.
      Local $NameToDelete1[6]  = _Excel_RangeFind($OpenWorkbook, "Smith, Bill") _ArrayDisplay($NameToDelete1, "Excel UDF: _Excel_RangeFind Example 1", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment") _Excel_RangeDelete($OpenWorkbook.ActiveSheet, $NameToDelete1[2], $xlShiftUp)  
      Please help, I wanted to have this program done yesterday but I did not see this problem until yesterday. 
    • AndyS19
      By AndyS19
      I'm trying to implement a Ctl-F popup box that looks something like the one that Notepad uses, but I'm not havine much luck.  I intend to get it working, then beef up the popup's contents to add several checkboxes, buttons and radio boxes.
      What my example code does is to use InputBox(), but that's not what I want.
      Here is my test code:
      #include <Array.au3> #include <GUIConstantsEx.au3> #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 Opt("GUICloseOnESC", 1) Opt("GUIOnEventMode", 1) Opt('MustDeclareVars', 1) OnAutoItExitRegister("ExitStageLeft") Opt("WinTitleMatchMode", -2) Global $hGUI _Main() Func _Main() $hGUI = GUICreate("Test ^F", 300, 200) setupSpecialKeysHandlers() GUISetOnEvent($GUI_EVENT_CLOSE, "Event_GUIClose") GUISetState() While (1) Sleep(157) WEnd EndFunc ;==>_Main Func handle_CTRL_F_key() Local $str $str = InputBox("Search", "Enter the string to search for:") ConsoleWrite("+++: $str ==>" & $str & "<==" & @CRLF) EndFunc ;==>handle_CTRL_F_key Func ExitStageLeft() Exit (99) EndFunc ;==>ExitStageLeft Func Event_GUIClose() Exit (1) EndFunc ;==>Event_GUIClose Func setupSpecialKeysHandlers() Local $ar, $parts, $key, $handler, $id Local $aAccelKeys[1][2] ; Create a table of Special keys and their handlers $ar = StringSplit("", "") _ArrayAdd($ar, "^f - handle_CTRL_F_key ") ReDim $aAccelKeys[UBound($ar) - 1][2] ; Now, create $aAccelKeys array with the table data. ; For each entry, create a Dummy GUI and associate its ; ID with the special key. For $ndx = 1 To UBound($ar) - 1 $parts = StringSplit($ar[$ndx], "-", 2) $key = StringStripWS($parts[0], 8) $handler = StringStripWS($parts[1], 8) $id = GUICtrlCreateDummy() $aAccelKeys[$ndx - 1][0] = $key $aAccelKeys[$ndx - 1][1] = $id GUICtrlSetOnEvent($id, $handler) Next GUISetAccelerators($aAccelKeys) ; Setup the Special keys hooks EndFunc ;==>setupSpecialKeysHandlers  
    • Atoxis
      By Atoxis
      Howdy, I've gone through a lot of au3 forums, and I once had a working Imagesearch script that I got from here.  However, and i'm just totally not sure how but my imagesearch scripts aren't working anymore.
      I'm not new to au3 but i'm not the most experienced with it's syntax/commands.

      Anyways, I've looked over the big threads involving imagesearch.

      Does anyone have a working Imagesearch x64 for win10 that is currently working as of the date with the post.

      Dll's and what not is fine, just when I tell the script to run, I want to be able to find the image on the screen!
      Can't find a working copy so if anyone has one please send it my way lol.

      I've taken all the imagesearch downloads and what not and have played with them but I can't get any of them working on my end, despite others saying they're working.
      Thanks.
    • tiye0405
      By tiye0405
      Hello, 
       
      I currently have a problem that deals with moving the mouse to a given location + or - a certain distance.
      $search1 =_WaitForImageSearch("envelope.bmp", 10, 1, $x, $y, 20)
      $search2 =_WaitForImageSearch("envelope2.bmp", 10, 1, $x, $y, 20)
       
      If $search1 = 1 Then
                  Sleep(100)
                  MouseMove($x, $y, 10)
                  sleep(99)
                  MouseClick("left")
                 Sleep(99)
      ElseIf $search2 = 1 Then
                 Sleep(100)
                 MouseMove($x, $y2, 10)
                 sleep(99)
                 MouseClick("left")
                 Sleep(100)
      Else
                Sleep(150)
                MouseMove($x2, $y, 10)
                Sleep(150)
                MouseClick("left")
               Sleep(150)
      EndIf
      The problem about this is that i defined $x2 = $x - 175  and $y2 = $y + 35
      I got these numbers ( 175 and 35) with the autoit helper and just subtracted point where it is to the point its supposed to move but it doesnt work.

      is there any proper way to find the distance between 2 points in pixels?
       
      Imgsearch doesnt always work for this picture so i want it to have a backup
       
      edit: could it be that the definition of $x and $y  from the previous image search arent there anymore and thats why it moves my mouse to strange places? 
      is there a way to preserve the $x $y from the previous img search untill the next succesful one?
       
       
×