Sign in to follow this  
Followers 0
FOM

ImageSearch need help please

10 posts in this topic

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

Share this post


Link to post
Share on other sites



#3 ·  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

Share this post


Link to post
Share on other sites

Learning by doing.

Thanks, I will look into it.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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

I couldnt find out why this happen.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites
9 minutes ago, FOM said:

I'm looking through hundreds of pictures

To what end?


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0