Hallo ich brauche Hilfe bei der ImageSearch funktion. Unzwar bekomm ich immer diese Fehlermeldung wenn ich eine Funktion starte die den ImageSearch beinhaltet:
Davor hatte ich keine PixelSearch.au3 Datei. hab sie vom internet gedownloadet und auch die .dll datei dafür. Trotzdem scheint was mit der Datei nicht zu stimmen...
Also beim StartUp läuft noch alles gut, auch das beenden geht. Aber wenn ich g drücke und somit die Funktion _Start , dann kommt der error
In der Meldung steht doch alles was du wissen musst: Der Fehler tritt in Zeile 45 der ImageSearch.au3 auf. Da wirst du wohl eine fehlerhafte Version gedownloadet haben.
Ändere die Zeile in
Code:
If IsArray($result) And $result[0] = 0 Then Return 0
oder suche dir eine korrekte .au3. Ich kann nicht genau sagen, wie sich die Änderung der Zeile auswirken wird. Sollte das Array noch einmal verwendet werden musst du vorher prüfen, ob $result überhaupt ein Array ist. Umschließe den Block einfach mit der IsArray() Abfrage.
In der Meldung steht doch alles was du wissen musst: Der Fehler tritt in Zeile 45 der ImageSearch.au3 auf. Da wirst du wohl eine fehlerhafte Version gedownloadet haben.
Ändere die Zeile in
Code:
If IsArray($result) And $result[0] = 0 Then Return 0
oder suche dir eine korrekte .au3. Ich kann nicht genau sagen, wie sich die Änderung der Zeile auswirken wird. Sollte das Array noch einmal verwendet werden musst du vorher prüfen, ob $result überhaupt ein Array ist. Umschließe den Block einfach mit der IsArray() Abfrage.
Ich kenn mich leider noch nicht so gut aus mit AutoIt. Wenn ich die Zeile mit deiner Zeile überschreibe kommt direkt der nächste Error in Z. 48
#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
; $transparency - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of
; the color to be used as transparency; can be omitted if
; not needed
;
; 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, $transparency = 0)
Return _ImageSearchArea($findImage, $resultPosition, 0, 0, @DesktopWidth, @DesktopHeight, $x, $y, $tolerance, $transparency)
EndFunc ;==>_ImageSearch
Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $transparency = 0)
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
If Not ($transparency = 0) Then $findImage = "*" & $transparency & " " & $findImage
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 IsArray($result) And $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 ;==>_ImageSearchArea
;===============================================================================
;
; 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
; $transparency - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of
; the color to be used as transparency can be omitted if
; not needed
;
; Return Value(s): On Success - Returns 1
; On Failure - Returns 0
;
;
;===============================================================================
Func _WaitForImageSearch($findImage, $waitSecs, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)
$waitSecs = $waitSecs * 1000
$startTime = TimerInit()
While TimerDiff($startTime) < $waitSecs
Sleep(100)
$result = _ImageSearch($findImage, $resultPosition, $x, $y, $tolerance, $transparency)
If $result > 0 Then
Return 1
EndIf
WEnd
Return 0
EndFunc ;==>_WaitForImageSearch
;===============================================================================
;
; 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
; $transparent - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of
; the color to be used as transparent; can be omitted if
; not needed
;
; 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, $transparency = 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, $transparency)
If $result > 0 Then
Return $i
EndIf
Next
WEnd
Return 0
EndFunc ;==>_WaitForImagesSearch
;~ ; find recycle bin if it is in the top left corner of screen
;~ ; change 2nd argument to 0 to return the top left coord instead
;~ $result = _ImageSearchArea("recycle.bmp", 1, 0, 0, 200, 200, $x1, $y1, 0, 0x000000) ;perfect black used as transparency
;~ If $result = 1 Then
;~ MouseMove($x1, $y1, 3)
;~ MsgBox(0, "Found", "Found a recycle bin with stuff in top left corner")
;~ EndIf
Kann jemand hier seine funktionierende Datei hochladen? Wäre nett
Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $transparency = 0)
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
If Not ($transparency = 0) Then $findImage = "*" & $transparency & " " & $findImage
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 IsArray($result) Then
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
Else
Return 0
EndIf
EndFunc ;==>_ImageSearchArea
Danke, du bist hier der einzige der mir hilft :/
Der Code beinhaltet nur die Imagesearcharea funktion. Aber mit @Desktopwidh und height kann ich doch eigentlich die funktion auch desktopübergreifend benutzen oder nicht? Habs mal probiert, bekomme keine fehlermeldung aber das bild wird nicht erkannt Egal ob .bmp mit 16 oder 254 farben oder ob .png ...
Nimmst du Coord oder Absolut als Koordinaten Mode, liegt eventuell daran.
Außerdem sollten die Bilder die du suchst am besten mit Lossless PNG komprimiert werden.
If - ElseIf / Imagesearch Hilfe 01/10/2014 - AutoIt - 6 Replies Hallo Community,
Ich brauch mal wieder eure Hilfe, weil ich nach langen Suchen und rumprobieren nicht weiter komme.
Func step2()
If _WaitForImageSearch("data/munze.bmp",600 00,1,$x,$y,10) > 0 Then ;sucht die Münze und findet sie *funktioniert
MouseClick("left", $x ,$y, 1, 1)
Sleep(500)
MouseClick("left", 686 ,374, 1, 10) ;spielt die Karte
ElseIf _WaitForImageSearch("data/munze.bmp",600 00,1,$x,$y,10) > 0 Then ;findet er die Münze nicht *funktioniert
Hilfe mit ImageSearch 08/25/2013 - AutoIt - 1 Replies Jo, wollte so 'nen simplen Cookieclicker-Bot machen und hab das Problem, dass er nicht anfängt iwas zu machen, bzw. er hovert nichtmal mit der Maus auf das Keks.bmp.
Code:
#include <ImageSearch.au3> Hotkeyset("{F2}","Ende") Func Ende () While 1 - Pastebin.com
Keks.bmp und ImageSearch dll sind natürlich im Ordner.
ImageSearch bitte um Hilfe 01/21/2011 - AutoIt - 4 Replies Tag allerseits ich bin noch ein zimlicher Anfänger was AuoIt betrifft meine einzige Erfahrung die ich bisher gemacht habe ist, habe mir einen Bot für Millionaire City gecoded welcher aber nur aus MouseMove und Mouse Click besteht...
Deshalb wollte ich das ganze mit ImageSearch verbessern, weil soviel ich weiss kann man damit bestimmte Bilder suchen und bekommt dann diese Koordinaten des Bildes zurück.
In meinem Fall wären das halt Häuser von welchen es auch mehrere der gleichen Sorte...
Hilfe bei einem AUtoIT imagesearch script 08/24/2010 - AutoIt - 2 Replies Nun,
Ich will ein Script, dass solange den Bildschirm SCHNELL nach dem Pixel 0x267042 sucht und immer wieder draufklickt, bis das Bild "gewonnen.PNG" sichtbar wird,dann da drauf klickt und wieder von vorne anfängt mit Pixelsearch.
Danke
dringen hilfe zu imagesearch 07/29/2010 - AutoIt - 8 Replies Hi ich habe mir auch die imagesearch demo angesehen werde aber nicht schlau^^.
Also ich habe diesen code:
#include <ImageSearch.au3>
;
; Demo on the functions of ImageSearch
; Assumes that you have a Recycle Bin icon at the top left of your screen
; Assumes that you have IE6 or 7 icon visible
; Please make the icon visible or we won't be able to find it