|
You last visited: Today at 16:40
Advertisement
Autoit
Discussion on Autoit within the AutoIt forum part of the Coders Den category.
04/14/2011, 10:06
|
#1
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1
Received Thanks: 0
|
Autoit
Hallo zusammen,
ich bräuchte mal ein wenig Hilfe und hoffe, es ist nicht unverschämt als Neuling gleich schon Fragen zu stellen.
Mein Problem:
In meinem Script (Autoit) soll ein Image gesucht werden (Image Search), ist es gefunden, sollen alle Pixel in diesem Image angeklickt werden.
Ist so etwas möglich?
Beispiel:
#include <ImageSearch.au3>
$x1 = 0
$y1 = 0
While 1
Sleep(1)
If $active = 1 Then
$result = _ImageSearch("c:\image.png", 1, $x1, $y1, 0)
If $result = 1 Then
MouseClick("LEFT", $x1, $x2)
Sleep(100)
EndIf
EndIf
Wend
Im moment wird also nur irgendwo das Image angeklickt (wo eigentlich?),
aber ich hätte gerne, dass das jedem Pixel widerfährt.
So sieht zum Beispiel ein Image aus:
Es hat in diesem Fall 25 x 25 Pixel.
Ich sage schon mal vielen Dank im voraus!
|
|
|
04/14/2011, 21:15
|
#2
|
elite*gold: 0
Join Date: Feb 2010
Posts: 344
Received Thanks: 151
|
Hier mal eine leicht editierte Version :
PHP Code:
#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,$x,$y,$tolerance, $dllopen = "") return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance,$dllopen) EndFunc
Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,$x,$y, $tolerance, $dllopen = "ImageSearchDLL.dll") ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage $result = DllCall($dllopen,"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) Return($x & "#" & $y) 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) $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
;=============================================================================== ; ; 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
Diese kannst du so verwenden :
PHP Code:
$return = _ImageSearch(@ScriptDir & "\Bild.bmp", 1, 0, 0, 0) If $return <> 0 Then $splits = StringSplit($return, "#") If IsArray($splits) Then If UBound($splits) >= 2 Then MouseClick("left", $splits[1], $splits[2]) EndIf EndIf EndIf
|
|
|
04/14/2011, 21:30
|
#3
|
elite*gold: 45
Join Date: Mar 2010
Posts: 1,561
Received Thanks: 350
|
achte bitte nächste mal darauf :
|
|
|
04/18/2011, 11:41
|
#4
|
elite*gold: 15
Join Date: Nov 2005
Posts: 13,021
Received Thanks: 5,324
|
|
|
|
All times are GMT +1. The time now is 16:41.
|
|