Aktuelles ImageSearch

  • Hallo Leute,

    ich beschäftige mich schon seit einiger Zeit mit AutoIT und möchte ich nun etwas im Bereich ImageSearch weiterbilden.

    Ich habe dafür schon eine UDF gefunden inc. DLL (sogar 2 - eine von 2008 die andere von 2010).

    Gibt es dafür eine neuere DLL? Am liebsten wäre es mir natürlich wenn es auch ganz ohne DLL funktionieren würde (man weiß ja nie was da noch alles drinsteht :) )

    Das Problem an den beiden DLLs ist: bei der 2008er Version stürzt AutoIT beim Aufruf ab und bei der 2010er Version passiert einfach garnichts ^^

    Mit freundlichen Grüßen

    Xanacas

  • Hi,
    erzähl mal, was du überhaupt machen möchtest.
    Meistens gibt es einfachere/sichere Lösungen und auch Methoden, um Bilder/Auschnitte zu finden welche völlig ohne Dll auszukommen.

  • Oh .. ich wusste doch, das ich etwas vergessen hatte :D

    Die UDF zu den DLLs sind identisch - daher lad ich nur mal eine hoch :)

    Mfg

    die imagesearch udf hat mir auch probs bereitet, mit den ganzen änderungen bei autoit war die udf auch bei mir nicht mehr lauf fähig...versuchs mal mit der abgeänderten, vielleicht gehts dann:

    Spoiler anzeigen
    [autoit]

    #include-once
    ; ------------------------------------------------------------------------------
    ;
    ; AutoIt Version: 3.0
    ; Language: English
    ; Description: Functions that assist with Image Search
    ; Require that the ImageSearchDLL.dll be loadable
    ;
    ; ------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Description: Find the position of an image on the desktop
    ; Syntax: _ImageSearchArea, _ImageSearch
    ; Parameter(s):
    ; $findImage - the image to locate on the desktop
    ; $tolerance - 0 for no tolerance (0-255). Needed when colors of
    ; image differ from desktop. e.g GIF
    ; $resultPosition - Set where the returned x,y location of the image is.
    ; 1 for centre of image, 0 for top left of image
    ; $x $y - Return the x and y location of the image
    ;
    ; Return Value(s): On Success - Returns 1
    ; On Failure - Returns 0
    ;
    ; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify
    ; a desktop region to search
    ;
    ;===============================================================================
    Func _ImageSearch($findImage,$resultPosition, ByRef $x, ByRef $y,$tolerance)
    return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom, ByRef $x, ByRef $y, $tolerance)
    ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
    if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
    $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)

    [/autoit] [autoit][/autoit] [autoit]

    ; If error exit
    if $result[0]="0" then return 0

    [/autoit] [autoit][/autoit] [autoit]

    ; Otherwise get the x,y location of the match and the size of the image to
    ; compute the centre of search
    $array = StringSplit($result[0],"|")

    [/autoit] [autoit][/autoit] [autoit]

    $x=Int(Number($array[2]))
    $y=Int(Number($array[3]))
    if $resultPosition=1 then
    $x=$x + Int(Number($array[4])/2)
    $y=$y + Int(Number($array[5])/2)
    endif
    return 1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Description: Wait for a specified number of seconds for an image to appear
    ;
    ; Syntax: _WaitForImageSearch, _WaitForImagesSearch
    ; Parameter(s):
    ; $waitSecs - seconds to try and find the image
    ; $findImage - the image to locate on the desktop
    ; $tolerance - 0 for no tolerance (0-255). Needed when colors of
    ; image differ from desktop. e.g GIF
    ; $resultPosition - Set where the returned x,y location of the image is.
    ; 1 for centre of image, 0 for top left of image
    ; $x $y - Return the x and y location of the image
    ;
    ; Return Value(s): On Success - Returns 1
    ; On Failure - Returns 0
    ;
    ;
    ;===============================================================================
    Func _WaitForImageSearch($findImage,$waitSecs,$resultPosition, ByRef $x, ByRef $y,$tolerance)
    $waitSecs = $waitSecs * 1000
    $startTime=TimerInit()
    While TimerDiff($startTime) < $waitSecs
    sleep(100)
    $result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance)
    if $result > 0 Then
    return 1
    EndIf
    WEnd
    return 0
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Description: Wait for a specified number of seconds for any of a set of
    ; images to appear
    ;
    ; Syntax: _WaitForImagesSearch
    ; Parameter(s):
    ; $waitSecs - seconds to try and find the image
    ; $findImage - the ARRAY of images to locate on the desktop
    ; - ARRAY[0] is set to the number of images to loop through
    ; ARRAY[1] is the first image
    ; $tolerance - 0 for no tolerance (0-255). Needed when colors of
    ; image differ from desktop. e.g GIF
    ; $resultPosition - Set where the returned x,y location of the image is.
    ; 1 for centre of image, 0 for top left of image
    ; $x $y - Return the x and y location of the image
    ;
    ; Return Value(s): On Success - Returns the index of the successful find
    ; On Failure - Returns 0
    ;
    ;
    ;===============================================================================
    Func _WaitForImagesSearch($findImage,$waitSecs,$resultPosition, ByRef $x, ByRef $y,$tolerance)
    $waitSecs = $waitSecs * 1000
    $startTime=TimerInit()
    While TimerDiff($startTime) < $waitSecs
    for $i = 1 to $findImage[0]
    sleep(100)
    $result=_ImageSearch($findImage[$i],$resultPosition,$x, $y,$tolerance)
    if $result > 0 Then
    return $i
    EndIf
    Next
    WEnd
    return 0
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    €: hab den code nochmal neu eingestellt...mir ist aufgefallen das beim ersten versuch ein paar ";" gesetzt wurden wo keine hingehören oO
    jetzt is es aber richtig leider immernoch nicht^^ in den zeilen 78, 81, 113 und 117 gehört der trenner nicht rein!

    noob aus erfahrung

    2 Mal editiert, zuletzt von oernzz (18. Oktober 2014 um 18:30)

  • ja, ich weiß doppelpost und so...sorry dafür, aber ich denke es is diesmal ok.
    irgendwie wird in dem script das im spoiler ist immer ein ";" eingesetzt wo keines hingehört, in diesem fall in den zeilen 78, 81, 113 und 117. wenn ich das aber editieren will sind die nicht da ?(

    hab ich was falsch gemacht oder ist das ein bug?

    mfg
    oernzz

    noob aus erfahrung

  • Das ist mir auch aufgefallen beim ausführen des Scripts :D

    aber mit dem Entfernen der ; entfallen auch die Fehler :)

    und vielen Dank für das Script - damit funktioniert alles wie es soll :)

    Mfg Xanacas