Jump to content

Recommended Posts

Posted

Hi,

finally I got the imageseach running.
 

#include <ImageSearch2015.au3>

$x1=0
$y1=0


$picture = "C:\dog.png"
Do
$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
until $result = 1;
if $result=1 Then
   MouseMove($x1,$y1,500)
 
   EndIf

But now I have the problem, if it cant find the picture its running non stop.
I was looking for a solution (example) but couldnt find anything.

Any help is appreciate, Thank you

Posted (edited)

I removed the  .until loop , that worked perfectly, thank you so much.

The only thing I cant figure out, that my mouse is now, when it cant find the picture, to the upper left corner of my desktop.

 

or, when I try to search for a second picture, it wont start

is the way I dot it  wrong?

 

$picture = "C:\dog.png"

$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
$result = 1;

if $result=1 Then
   MouseMove($x1,$y1,500)

EndIf

sleep (1500)

$picture = "C:\cat.png"

$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
$result = 1;

if $result=1 Then
   MouseMove($x1,$y1,500)

EndIf

Ok, I changed in

 

$picture = "C:\dog.png"

$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
$result = 1;

if $result=1 Then
   MouseMove($x1,$y1,500)
   MouseClick("left")


sleep (1500)

$picture = "C:\cat.png"

$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
$result = 1;

if $result=1 Then
   MouseMove($x1,$y1,500)
   MouseClick("left")
EndIf

EndIf

and it worked.

 

Maybe not the nicest script, but I'm happy like a little girl right now

Edited by FOM
Posted
7 hours ago, FOM said:

Ok, I changed in

 

$picture = "C:\dog.png"

$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
$result = 1;

if $result=1 Then
   MouseMove($x1,$y1,500)
   MouseClick("left")


sleep (1500)

$picture = "C:\cat.png"

$result = _ImageSearch($picture,1,$x1,$y1,0,0)
;_ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance, $transparency = 0)

ConsoleWrite($result)
$result = 1;

if $result=1 Then
   MouseMove($x1,$y1,500)
   MouseClick("left")
EndIf

EndIf

and it worked.

this can't be the solution, just changing the result to 1 in every case. What happens when the picture isn't found?

Posted

then the mouse moves to the upper left corner of my Desktop and klicks.

I couldnt find out why this happen.

Posted
56 minutes ago, FOM said:

I couldnt find out why this happen.

It happens because the manualy seting of result. I don't use ImageSearch as it is ugly. It's only for games realy needed, in all other cases there are better solutions possible.

Posted

well, I'm new with AutoIt and I'm looking through hundreds of pictures and I thought ImageSearch would be the easiest way for it.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...