FOM Posted September 12, 2016 Share Posted September 12, 2016 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 More sharing options...
JohnOne Posted September 12, 2016 Share Posted September 12, 2016 Remove the do...until loop, or add a timeout using timerdiff() AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FOM Posted September 12, 2016 Author Share Posted September 12, 2016 (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 September 12, 2016 by FOM Link to comment Share on other sites More sharing options...
JohnOne Posted September 13, 2016 Share Posted September 13, 2016 Ace, what you should do now is write it into a function which takes a path to an image as a parameter. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FOM Posted September 13, 2016 Author Share Posted September 13, 2016 Learning by doing. Thanks, I will look into it. Link to comment Share on other sites More sharing options...
AutoBert Posted September 13, 2016 Share Posted September 13, 2016 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 More sharing options...
FOM Posted September 13, 2016 Author Share Posted September 13, 2016 then the mouse moves to the upper left corner of my Desktop and klicks. I couldnt find out why this happen. Link to comment Share on other sites More sharing options...
AutoBert Posted September 13, 2016 Share Posted September 13, 2016 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. Link to comment Share on other sites More sharing options...
FOM Posted September 13, 2016 Author Share Posted September 13, 2016 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. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 13, 2016 Moderators Share Posted September 13, 2016 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now