Imagesearch geht nicht ... it If Abfrage immer Fehler als antwort !

  • Guten Tag ,

    ich habe vor gehabt etwas mit Imagesearch zu machen nur findet er das bild bzw den bildausschnitt nicht-,-

    Hier mein Code :

    Spoiler anzeigen
    [autoit]


    #cs ----------------------------------------------------------------------------

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

    AutoIt Version: 3.3.0.0
    Author: myName

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

    Script Function:
    Template AutoIt script.

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

    #ce ----------------------------------------------------------------------------

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

    ; Script Start - Add your code below here

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

    #include <ImageSearch.au3>

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

    HotKeySet("{F5}" , "start")
    HotKeySet("{F6}" , "stop")

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

    while 1
    sleep(999999999999999999999)
    WEnd
    Func start ()
    $x1=0
    $y1=0
    $result = _ImageSearch("Unbenannt.bmp",1,$x1,$y1,0)
    if $result=1 Then
    MouseMove($x1,$y1,3)
    MsgBox(0,"Gefunden","Da ist es ")
    Else
    msgbox(0,"Nichts gefunden","sry nix gefunden")
    EndIf

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

    $result = _ImageSearch("Unbenannt.bmp",0,$x1,$y1,0)
    if $result=1 Then
    MouseMove($x1,$y1,3)
    MsgBox(0,"Gefunden","Da ist es ")
    Else
    msgbox(0,"Nichts gefunden","sry nix gefunden")
    EndIf
    EndFunc

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

    func stop()
    Exit
    EndFunc

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

    Hier die Imagesearch die ich in dem Ordner Includes vom AutoIt ordner habe :

    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>10 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

    ; 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],"|")

    $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]

    Was mache ich falsch ? ? ?
    Ich hoffe ihr könnt mir helfen..

  • [quote='AciDDreaM',index.php?page=Thread&postID=106726#post106726]Guten Tag ,

    ich habe vor gehabt etwas mit Imagesearch zu machen nur findet er das bild bzw den bildausschnitt nicht-,-

    Hier mein Code :

    Spoiler anzeigen
    [autoit]


    #cs ----------------------------------------------------------------------------

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

    AutoIt Version: 3.3.0.0
    Author: myName

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

    Script Function:
    Template AutoIt script.

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

    #ce ----------------------------------------------------------------------------

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

    ; Script Start - Add your code below here

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

    #include <ImageSearch.au3>

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

    HotKeySet("{F5}" , "start")
    HotKeySet("{F6}" , "stop")

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

    while 1
    sleep(999999999999999999999)
    WEnd
    Func start ()
    $x1=0
    $y1=0
    $result = _ImageSearch("Unbenannt.bmp",1,$x1,$y1,0)
    if $result=1 Then
    MouseMove($x1,$y1,3)
    MsgBox(0,"Gefunden","Da ist es ")
    Else
    msgbox(0,"Nichts gefunden","sry nix gefunden")
    EndIf

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

    $result = _ImageSearch("Unbenannt.bmp",0,$x1,$y1,0)
    if $result=1 Then
    MouseMove($x1,$y1,3)
    MsgBox(0,"Gefunden","Da ist es ")
    Else
    msgbox(0,"Nichts gefunden","sry nix gefunden")
    EndIf
    EndFunc

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

    func stop()
    Exit
    EndFunc

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


    MouseMove($x1,$y1,3) --------- so wie ich es verstehe geben $x1,$y1 die Startkoordinaten der Suche an, Deine Maus dürfte also wenn
    das Bild gefunden wird auf den Seitenanfang springen, die Koordinaten des "Fundortes" sind wahrscheinlich in $result zu finden ??!!??

  • ich hab ein anderes problem.
    und zwar will ich ein bild in einem fenster suchen.
    am desktop (hintergrundbild) findet er den ausschnitt den ich suchen will aber sobald ich in einem fenster einen ausschnitt suchen will findet er nichts

    Spoiler anzeigen

    #include <ImageSearch.au3>

    $x1=0
    $y1=0

    $result = _ImageSearchArea("hh.bmp",1,0,0,1680,1050,$x1,$y1,0)
    if $result=1 Then
    MouseMove($x1,$y1,3)
    MsgBox(0,"Found","gefunden")
    EndIf


    bitte schnelle hilfe

  • das problem hab ich grade gelöst
    es lag an den bildern. anscheinend haben dich manche pixel beim bearbeiten und zurechtschneiden verändert
    und nun klappt es :D