Jump to content

Recommended Posts

Posted

I'm searched everywhere and did countless hours of trying to fix this but I just cant get it going.
Im trying to search for an image with a transparency because the image im looking for the background always changes
not allowing me to find it using imagesearch with .bmp files.

I've made a small demonstration photo below of example I've tried with different colored backgrounds none of them worked.

 

cr(">" & "_ImageSearchStartup()=" & _ImageSearchStartup(), 2)
    OnAutoItExitRegister(_ImageSearchShutdown)

    cr("!Testing...")
    ;using Notepad as a simple example
    #Region Notepad Snapshot Creation
    $hWin = WinGetHandle("24bit.png - Paint")
    If Not IsHWnd($hWin) Then
        If Run("mspaint.exe") = 0 Then cr("Couldn't run notepad.exe")
        Local $hWin = WinWait("24bit.png - Paint", "", 10)
        If $hWin = 0 Then cr("Notepad WinWait Timeout!")
    EndIf
    WinSetState($hWin, "", @SW_RESTORE)
    WinSetState($hWin, "", @SW_SHOW)
    WinActivate($hWin)
    Local $testimage = "24bit.png"
    _ScreenCapture_CaptureWnd($testimage, $hWin, 0, 0, -1, -1, False);_ScreenCapture_CaptureWnd ( $sFileName, $hWnd [, $iLeft = 0 [, $iTop = 0 [, $iRight = -1 [, $iBottom = -1 [, $bCursor = True]]]]] )
    cr("made Notepad Window screenshot")
    #EndRegion Notepad Snapshot Creation
Local $h_ImageSearchDLL = -1; Will become Handle returned by DllOpen() that will be referenced in the _ImageSearchRegion() function
Local $y = 0, $x = 0, $result
    $result = _ImageSearch($testimage, 1, $x, $y, 0, 0);_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)



   Local $testimage1 = "transwhite.png"
   Local $y1 = 0, $x1 = 0, $result1 ;
    $result1 = _ImageSearch($testimage1, 1, $x1, $y1, 0,  0xFFFFFF);_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)  $result1 = _ImageSearchArea("trans.bmp", 1, 0, 0, @DesktopWidth, @DesktopHeight, $x1, $y1, 0, 0xff00ff)
   if $result1 =1 Then
      MouseMove ($x1, $y1, 0)

      cr("+" & "recognised image")
   EndIf

 

e-JCtY9xRR6NMRIQMtd-Mw.png

ImageSearch2015.au3

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...