|
You last visited: Today at 00:05
Advertisement
AutoIT - ImageSearch läuft nicht richtig.
Discussion on AutoIT - ImageSearch läuft nicht richtig. within the AutoIt forum part of the Coders Den category.
11/24/2017, 20:07
|
#16
|
elite*gold: 39
Join Date: Nov 2017
Posts: 22
Received Thanks: 1
|
Quote:
Originally Posted by elmarcia
change
_ImageSearchArea($path,1,$x,$y,$x+$ds,$y+$ds,$fx,$fy,10)
to
_ImageSearchArea($path,0,$x,$y,$x+$ds,$y+$ds,$fx,$ fy,10)
and see if that works
|
little bit closer but it still not hit it :/
|
|
|
11/25/2017, 01:32
|
#17
|
elite*gold: 0
Join Date: Nov 2012
Posts: 9
Received Thanks: 0
|
Kann doch nicht sein. Was ein seltsames Problem.
Poste doch (noch einmal) deinen ganzen Code. Dazu auch das, was in der ImageSearch.au3 ist. Eventuell hat es jmd. an der Stelle bearbeitet (/angepasst), bevor es in deine Hände kam.
|
|
|
11/25/2017, 09:19
|
#18
|
elite*gold: 39
Join Date: Nov 2017
Posts: 22
Received Thanks: 1
|
Quote:
Originally Posted by GyRb!
Kann doch nicht sein. Was ein seltsames Problem.
Poste doch (noch einmal) deinen ganzen Code. Dazu auch das, was in der ImageSearch.au3 ist. Eventuell hat es jmd. an der Stelle bearbeitet (/angepasst), bevor es in deine Hände kam.
|
Okay dann alles zusammengefasst:
Bei mir steht folgendes:
Code:
#include "ImageSearch2015.au3"
_ImageSearchStartup()
Global $x= 0,$y = 0
$centerImage = 0; 0 top left corner - 1 center of image
$data = _ImageSearch("geld.png",$centerImage,$x,$y,10)
MouseMove($x,$y)
;use to search for images in specific rectangle -> Faster than search entire desktop
; _ImageSearchArea($imgpath,$searchCenter,$xo,$yo,$width,$height,$x,$y,$tolerance)
_ImageSearchShutdown()
Und folgendes steht in meine ImageSearch.au3:
#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,@D esktopWidth,@DesktopHeight,$x,$y,$tolerance,$HBMP)
EndFunc
Func _ImageSearchArea($findImage,$resultPosition,$x1,$y 1,$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:\Users\Fidibus\Documents\imgsrc_test\Im ageSearchDLLx64.dll","str","ImageSearch","int",$x1 ,"int",$y1,"int",$right,"int",$bottom,"str",$findI mage,"ptr",$HBMP)
Else
$result = DllCall("C:\Users\Fidibus\Documents\imgsrc_test\Im ageSearchDLLx64.dll","str","ImageSearch","int",$x1 ,"int",$y1,"int",$right,"int",$bottom,"ptr",$findI mage,"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,$resultPo sition,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,$resultP osition,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
|
|
|
11/25/2017, 16:37
|
#19
|
elite*gold: 0
Join Date: Nov 2012
Posts: 9
Received Thanks: 0
|
Servus.
Mein Fehler. Natürlich braucht es nicht die ImageSearch.au3.
Sondern deinen Include. Also die Imagesearch2015.au3.
(Hättest aber auch dran denken können. :P)
cheers.
|
|
|
11/26/2017, 13:47
|
#20
|
elite*gold: 39
Join Date: Nov 2017
Posts: 22
Received Thanks: 1
|
Quote:
Originally Posted by GyRb!
Servus.
Mein Fehler. Natürlich braucht es nicht die ImageSearch.au3.
Sondern deinen Include. Also die Imagesearch2015.au3.
(Hättest aber auch dran denken können. :P)
cheers.
|
Sorry der geht auf meine Kappe
Code:
#AutoIt3Wrapper_UseX64=y ; Set to Y or N depending on your situation/preference!!
#include-once
#include <WinAPIFiles.au3> ; for _WinAPI_Wow64EnableWow64FsRedirection
#include <ScreenCapture.au3> ;_ScreenCapture_CaptureWnd etc. ;using this in the example to create a test image, otherwise not neccessary here
#Region When running compiled script, Install needed DLLs if they don't exist yet
If Not FileExists("ImageSearchDLLx32.dll") Then FileInstall("ImageSearchDLLx32.dll", "ImageSearchDLLx32.dll", 1);FileInstall ( "source", "dest" [, flag = 0] )
If Not FileExists("ImageSearchDLLx64.dll") Then FileInstall("ImageSearchDLLx64.dll", "ImageSearchDLLx64.dll", 1)
If Not FileExists("msvcr110d.dll") Then FileInstall("msvcr110d.dll", "msvcr110d.dll", 1);Microsoft Visual C++ Redistributable dll x64
If Not FileExists("msvcr110.dll") Then FileInstall("msvcr110.dll", "msvcr110.dll", 1);Microsoft Visual C++ Redistributable dll x32
#EndRegion
Local $h_ImageSearchDLL = -1; Will become Handle returned by DllOpen() that will be referenced in the _ImageSearchRegion() function
#Region ImageSearch Startup/Shutdown
Func _ImageSearchStartup()
_WinAPI_Wow64EnableWow64FsRedirection(True)
$sOSArch = @OSArch ;Check if running on x64 or x32 Windows ;@OSArch Returns one of the following: "X86", "IA64", "X64" - this is the architecture type of the currently running operating system.
$sAutoItX64 = @AutoItX64 ;Check if using x64 AutoIt ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt.
If $sOSArch = "X86" Or $sAutoItX64 = 0 Then
cr("+>" & "@OSArch=" & $sOSArch & @TAB & "@AutoItX64=" & $sAutoItX64 & @TAB & "therefore using x32 ImageSearch DLL")
$h_ImageSearchDLL = DllOpen("ImageSearchDLLx32.dll")
If $h_ImageSearchDLL = -1 Then Return "DllOpen failure"
ElseIf $sOSArch = "X64" And $sAutoItX64 = 1 Then
cr("+>" & "@OSArch=" & $sOSArch & @TAB & "@AutoItX64=" & $sAutoItX64 & @TAB & "therefore using x64 ImageSearch DLL")
$h_ImageSearchDLL = DllOpen("ImageSearchDLLx64.dll")
If $h_ImageSearchDLL = -1 Then Return "DllOpen failure"
Else
Return "Inconsistent or incompatible Script/Windows/CPU Architecture"
EndIf
Return True
EndFunc ;==>_ImageSearchStartup
Func _ImageSearchShutdown()
DllClose($h_ImageSearchDLL)
_WinAPI_Wow64EnableWow64FsRedirection(False)
cr(">" & "_ImageSearchShutdown() completed")
Return True
EndFunc ;==>_ImageSearchShutdown
#EndRegion ImageSearch Startup/Shutdown
#Region ImageSearch UDF;slightly modified
; ------------------------------------------------------------------------------
;
; 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 True
; On Failure - Returns False
;
; 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 = 0, $transparency = 0);Credits to Sven for the Transparency addition
If Not FileExists($findImage) Then Return "Image File not found"
If $tolerance < 0 Or $tolerance > 255 Then $tolerance = 0
If $h_ImageSearchDLL = -1 Then _ImageSearchStartup()
If $transparency <> 0 Then $findImage = "*" & $transparency & " " & $findImage
If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
$result = DllCall($h_ImageSearchDLL, "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)
If @error Then Return "DllCall Error=" & @error
If $result = "0" Or Not IsArray($result) Or $result[0] = "0" Then Return False
$array = StringSplit($result[0], "|")
If (UBound($array) >= 4) Then
$x = Int(Number($array[2])); Get the x,y location of the match
$y = Int(Number($array[3]))
If $resultPosition = 1 Then
$x = $x + Int(Number($array[4]) / 2); Account for the size of the image to compute the centre of search
$y = $y + Int(Number($array[5]) / 2)
EndIf
Return True
EndIf
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)
If _ImageSearch($findImage, $resultPosition, $x, $y, $tolerance, $transparency) Then
Return True
EndIf
WEnd
Return False
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)
If _ImageSearch($findImage[$i], $resultPosition, $x, $y, $tolerance, $transparency) Then
Return $i
EndIf
Next
WEnd
Return False
EndFunc ;==>_WaitForImagesSearch
#EndRegion ImageSearch UDF;slightly modified
#Region My Custom ConsoleWrite/debug Function
Func cr($text = "", $addCR = 1, $printTime = False) ;Print to console
Static $sToolTip
If Not @Compiled Then
If $printTime Then ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & ":" & @MSEC & " ")
ConsoleWrite($text)
If $addCR >= 1 Then ConsoleWrite(@CR)
If $addCR = 2 Then ConsoleWrite(@CR)
Else
If $printTime Then $sToolTip &= @HOUR & ":" & @MIN & ":" & @SEC & ":" & @MSEC & " "
$sToolTip &= $text
If $addCR >= 1 Then $sToolTip &= @CR
If $addCR = 2 Then $sToolTip &= @CR
ToolTip($sToolTip)
EndIf
Return $text
EndFunc ;==>cr
#EndRegion My Custom ConsoleWrite/debug Function
|
|
|
11/26/2017, 23:09
|
#21
|
elite*gold: 0
Join Date: Nov 2012
Posts: 9
Received Thanks: 0
|
Was spuckt'n die Msgbox für $data aus?
MsgBox(0,"",$data) in die Zeile nach "$data = ..." einfügen.
|
|
|
11/27/2017, 15:57
|
#22
|
elite*gold: 39
Join Date: Nov 2017
Posts: 22
Received Thanks: 1
|
Quote:
Originally Posted by GyRb!
Was spuckt'n die Msgbox für $data aus?
MsgBox(0,"",$data) in die Zeile nach "$data = ..." einfügen.
|
Da steht dann "True".
|
|
|
04/11/2018, 20:29
|
#23
|
elite*gold: 0
Join Date: Mar 2018
Posts: 1
Received Thanks: 0
|
Works on 1st try - ImageSearch2015.au3
Installed 64 Bit AutoIt
Perfect Thx!
|
|
|
|
|
Similar Threads
|
autoit findet mit imagesearch das bild im spiel nicht oO?
01/21/2010 - AutoIt - 7 Replies
hallo,
ich habe folgendes programm geschrieben:
#include <ImageSearch.au3>
Global $fenster
Global $active = 0
$x = 0
$y = 0
|
[GUIDE] AutoIt ImageSearch
10/18/2009 - Metin2 Guides & Templates - 14 Replies
Ein sehr praktischer Befehl in AutoHotkey: ImageSearch. (http://www.autohotkey.com/docs/commands/ImageSear ch.htm)
Was macht der Befehl?- er sucht den ganzen Bildschrim nach einem Vorgegebenen Bild ab. Vielleicht auch Nützlich für den Angelbot, weil die Leute nicht mehr Pixel suchen müsen, sondern nuch noch Screens machen müssen!
Diesen Befehl gibt es auch für AutoIt!
_________________________________________________ ___________________________
. Kopiere die ImageSearchDLL.dll in...
|
autoit pixelsearch bzw imagesearch
02/04/2009 - General Coding - 0 Replies
hi leute,
ich hab mir nen bot mit autoit programmiert. Es ist n Browsergame, das auf Flash basiert. Ich habe Imagesearch benutzt und alles funkzt prima.
Das Problem:
Der Pc ist immer besetzt, wenn ich botte...
Also meine Frage: Gibts da ne alternative zu ImageSearch, die auch in minimierten Fenstern funktioniert?
|
All times are GMT +2. The time now is 00:05.
|
|