Damit man nicht lange lesen muss....! Lösung in meinem Fall:
[ gelöst ] ImageSearch funktioniert nicht.
Die von mir verwendeten Dateien hab ich auch mal als Anhang hochgeladen.
Thema "ImageSearch funktioniert nicht" somit "gelöst".
Halli hallo!
Bin gerade halb am verzweifeln. Wollte mal ein wenig mit ImageSearch basteln.
Habe mein Script auf ein Minimum gekürzt jetzt und da geht trotzdem nix!
Hier mein Script:
[autoit]#include <ImageSearch.au3>
[/autoit][autoit][/autoit][autoit]$x1 = 0
$y1 = 0
$res = _ImageSearch("Search.bmp", 1, $x1, $y1, 10)
[/autoit][autoit][/autoit][autoit]If $res = 1 Then
MouseClick("left", $x1, $y1, 10)
sleep(500)
Else
MsgBox(64, "Status:" "Es konnte keine Übereinstimmung ermittelt werden!")
EndIf
C:\Program Files (x86)\AutoIt3\Include\ImageSearch.au3 (44) : ==> Subscript used with non-Array variable.:
if $result[0]="0" then return 0
if $result^ ERROR
>Exit code: 1 Time: 0.213
Davon ab habe ich die Datei "ImageSearch.au3" im Includeverzeichnis. Die Datei "ImageSearch.dll" ist sowohl im Verzeichnis "Windows", als auch unter "Programme (x86)"...denk mal letzteres ist korrekt bei Win7, wenn ich mir die Fehlermeldung anschaue?
Hatte es vorher in einer Func, aber das hat auch nicht funktioniert und habe auch die Dateien 2 mal runter geladen und beide (also gesammt 4 Dateien) versucht..dachte mir vllt ist ja eine beschädigt oder veraltet...wie auch immer....! Habs auch bereits mit "Global $x1 = 0" und "Global $y1 = 0" versucht. Habe es mit *npng, als auch *.bmp versucht gehabt. Allerdings vermute ich auf Grund der Fehlermeldung eher einen anderen Fehler....nur das ich nicht den geringsten Schimmer habe, wo ich da ansetzen sollte!
Kann mir jemand einen Fehler sagen? Falls nein - kann mir wer sagen, wo ich diese beiden Dateien funktionstüchtig runterladen kann (aktuell) ?
Bin gerade absolut ratlos und prockel nu schon ne gefühlte Ewigkeit daran herum...ohne den geringsten Erfolg.
edit: Inhalt meiner ImageSearch.au3:
Spoiler anzeigen
#include-once
; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.0
; Language: English
; Description: Functions that assist with Image Search
; Require that the ImageSearchDLL.dll be loadable
;
; ------------------------------------------------------------------------------
;===============================================================================
;
; 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, $HBMP=0)
return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance,$HBMP)
EndFunc
Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance,$HBMP=0)
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage
If IsString($findImage) Then
$result = DllCall("C:\ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP)
Else
$result = DllCall("C:\ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr",$findImage,"ptr",$HBMP)
EndIf
; 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
;===============================================================================
;
; 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,$HBMP=0)
;$waitSecs = $waitSecs * 1000
;$startTime=TimerInit()
While TimerDiff($startTime) < $waitSecs
sleep(100)
$result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance,$HBMP)
if $result > 0 Then
return 1
EndIf
WEnd
return 0
EndFunc
;===============================================================================
;
; 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,$HBMP=0)
$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,$HBMP)
if $result > 0 Then
return $i
EndIf
Next
WEnd
return 0
EndFunc