mardi 14 avril 2015

Image Search using AutoIt

Im just trying to do a simple ImageSearch script usig AutoIt. But I cant get it to work propely even tho Im sure the image Im searching for is on the screen.


Here is my code:



#include <ImageSearch.au3>
global $x , $y

HotKeySet ("{F1}",StartScriptc)
HotKeySet ("{F2}",StopScript)

While 1
Sleep(200)
WEnd

Func StartScriptc()
;WinActivate("MyWindow")
FindPicture()
EndFunc

Func StopScript()
Exit
EndFunc

Func FindPicture()
While 1
ConsoleWrite ("Before search" & @CRLF)
$search = _ImageSearch("test2.bmp",0,$x,$y,50)
if $search = 1 Then
ConsoleWrite ("Found it!" & @CRLF)
Else
ConsoleWrite ("Fail!" & @CRLF)
EndIf
WEnd
EndFunc


When I run this code I get the "Before Search" output but it never passes to the lines after the _ImageSearch() function. Instead the scipt just ends (I guess its a crash) Here is the output I get:



Before search


14:10:51 AutoIt3.exe ended.rc:-1073741819


14:10:51 AutoIt3Wrapper Finished.


Exit code: 3221225477 Time: 9.844



I am not the author of ImageSearch.au3, its from http://ift.tt/1JGC620. I have tried both the 32 and 64 bit versions without success. I put the DLL and ImageSearch script into the same folder as my .bmp file and test script.


Aucun commentaire:

Enregistrer un commentaire