ImageSearch [x- und y-Koordinaten in ein Array] --> ERROR
-
- [ offen ]
-
Bloody JuJu -
8. Mai 2012 um 22:47 -
Geschlossen -
Erledigt
-
-
Kann man nix zu sagen _ImageSearch ist keinen Standardfunktion von Autoit.
-
-
Warst schneller als mein edit hehe. Wie gesagt ist _ImageSearch keine Standardfunktion von daher keine Ahnung was für Paramater da erwartet werden.
-
Code
Alles 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) return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance) EndFunc 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) ; 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 1Dort einmal die gekürzte Imegsearch.au3

Vllt. kannst du mir danach weiterhelfenSobald ich $x nicht als Array sondern einzelnt als $x1 schreibe klappts... Naja von daher denke ich mal das in ImageSearch das Array einfach nicht genommen werden kann.
-
Spoiler anzeigen
[autoit]Global $x[17], $y[17]
[/autoit] [autoit][/autoit] [autoit]
Global $sPath = @DesktopDir &"\"$result0 = _ImageSearch($sPath & "test.png", 1, $x[0], $y[0], 130)
[/autoit] [autoit][/autoit] [autoit]
MsgBox (0, "", $result0)Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance)
[/autoit] [autoit][/autoit] [autoit]
return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance)
EndFuncFunc _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance)
[/autoit] [autoit][/autoit] [autoit]
;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); If error exit
[/autoit] [autoit][/autoit] [autoit]
if $result[0]="0" then return 0; Otherwise get the x,y location of the match and the size of the image to
[/autoit] [autoit][/autoit] [autoit]
; compute the centre of search
$array = StringSplit($result[0],"|")$x=Int(Number($array[2]))
[/autoit]
$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
EndFuncDer Code da oben funktioniert bei mir wunderbar. Dein Fehler muss irgendwo anders begraben sein.
-
-
Das ist aber ein ganz anderer Fehler...

Führe das Script mal in Scite mit F5 aus, oder aus dem Ordner mit einem Rechtsklick -> Run Script (x86). -
Imagesearchdll.dll im Verzeichnis?
-
Führe meine Scripts immet via F5 aus und ImagesearchsearchDLL ist im System32 ordner

-
Dort gehört die aber nicht hin...
Mach die DLL in SysWOW64 rein. Dann klappt das alles auch.
-
Auch dort befindet sich die DLL. Hab sie auch nochmal ersetzt, trotzdem kein Glück.
EDIT: Fehelr behoben:
Zitat#AutoIt3Wrapper_UseX64=n
Nun noch der andere Fehler, den ich oben beschrieben habe beheben^^
Ein auschnitt vom Script nochmal:
CodeFunc TEST() Do $result0 = _ImageSearch($sPath & "Test.png", 1, $x[0], $y[0], 130) Until $result0 = 1 MouseMove($x[0], $y[0], 1) Sleep("100") EndFuncDiese wird mittels Hotkey aufgerufen, hmmm