Jump to content

ImageSearch need help please


FOM
 Share

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
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?

Link to comment
Share on other sites

  • Moderators
9 minutes ago, FOM said:

I'm looking through hundreds of pictures

To what end?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...