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

    • 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?
       
       
    • b9k
      By b9k
      Hi, I am stuck on a GUI problem and would like your help to solve it.
      I am trying to automate the SoundWire Server app to match my current system volume level while it is minimized to the notification area (so no clicking or stealing focus),
      I can already get the handle and alter the tracker position by sending a WM_SETPOS message, but somehow the actual volume is not changed: I think I need to do something else to trigger the event handler for the value change and propagate it correctly.
      This is the control summary from Au3 info:
      >>>> Window <<<< Title: SoundWire Server Class: #32770 Position: 441, 218 Size: 566, 429 Style: 0x94CA00C4 ExStyle: 0x00050101 Handle: 0x0000000000510E12 >>>> Control <<<< Class: msctls_trackbar32 Instance: 4 ClassnameNN: msctls_trackbar324 Name: Advanced (Class): [CLASS:msctls_trackbar32; INSTANCE:4] ID: 6002 Text: Position: 51, 222 Size: 47, 126 ControlClick Coords: 1, 101 Style: 0x5001000A ExStyle: 0x00000000 Handle: 0x00000000001234C8 >>>> Mouse <<<< Position: 496, 567 Cursor ID: 2 Color: 0xF0F0F0 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< Default multimedia device Tray on Start Static Server Address: 192.168.1.8 Status: Connected to B9K~OP3 Audio Output Audio Input Level Record to File Input Select: 44.1 kHz Minimize to Master Volume Mute >>>> Hidden Text <<<< Slider2 Mute OK Cancel Label Balance Slider1 Volume Front L/R Fr C/LFE Side L/R Back L/R
      I am attaching the program in question so you don't have to install it (i don't know if it is portable enough, tough): 

      SoundWire Server_files.zip

      Thanks in advance and I hope I didn't post in the wrong section
    • lenclstr746
      By lenclstr746
      HELLO GUYS
      I'm a work on a background see and click bot project 
      I can complete it if your help me
      (using imagesearch , gdi+ and  fastfind)
    • TheAutomator
      By TheAutomator
      Is this better to check a variable before you assign it to a value that could be the same?
      for example:
      local $EmptyLog = false func WriteLog($text) _guictrledit_appendtext($log, ($EmptyLog ? @CRLF : $empty) & $text) If $EmptyLog Then $EmptyLog = False endfunc or does AutoIt behind the scenes already check this?
      i guess overwriting memory with the same value over and over again is not good if you can prevent this with a check?
    • dadalt95
      By dadalt95
      Perform a simple google search!
      The script below works fine until fill the google form!
      What I can't find is how to submit the form, tried a couple of ways and none of them worked.

       
      #include <IE.au3> $oIE = _IECreate ("www.google.com") $o_form = _IEFormGetObjByName ($oIE, "f") $o_login = _IEFormElementGetObjByName ($o_form, "q") $username = "80251369" _IEFormElementSetValue ($o_login, $username) $o_numer = _IEGetObjByName($o_form, "btnK") _IEAction ($o_numer, "click")  
      The code runs without any problem.
      I don't know how to proceed!
      Thanks in advance!
×