SBrix Posted February 15, 2014 Share Posted February 15, 2014 As the title says. I have been having problems with my script. I want it to keep looking for an image, and if it can't find it then it should wait 5 seconds and try to look for it again. I am beginner so go easy on me. My script so far: #include <imagesearch.au3> Hotkeyset("s", 'start') Hotkeyset("x", 'stop') $x = 0 $y = 0 Func start() $search = _imagesearch('1pixel.bmp', 0, $x, $y, 0) If $Search = 1 Then Mousemove($x, $y,10) EndIf EndFunc While 1 sleep(5000) MouseClick("left") ExitLoop WEnd While 1 $search = _imagesearch('finish.bmp', 0, $x, $y, 0) If $Search = 1 Then Mousemove($x, $y,10) ExitLoop EndIf If $Search = 0 Then Sleep(5000) EndIf WEnd func stop() Exit EndFunc Link to comment Share on other sites More sharing options...
JohnOne Posted February 15, 2014 Share Posted February 15, 2014 What exactly are your problems? Be as verbose as you like. 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...
SBrix Posted February 15, 2014 Author Share Posted February 15, 2014 Imagine you opning a video using Windows Media Player. You go into fullscreen and watch the video. When the video is done it automatically go out of fullscreen. Now what I want is for the script to exit Windows Media Player as soon as the video ends. So basically a script that keep searching for the "red x" and when the "red x" becomes visible then moves to that position and click on it. And perhaps shutdown the computer after doing so. I just found AutoIT and became interested in it, so I am trying to create small, but useful scripts. I hope I explained it so you can understand. Link to comment Share on other sites More sharing options...
JohnOne Posted February 15, 2014 Share Posted February 15, 2014 I understand the question, but you have not explained the problem, at a glance your code looks like it should work. 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...
SBrix Posted February 15, 2014 Author Share Posted February 15, 2014 Whoops. It seems to be working now. I believe it was a corrupted .bmp file. Sorry for wasting your time . Link to comment Share on other sites More sharing options...
SBrix Posted February 15, 2014 Author Share Posted February 15, 2014 Question. If "$Search" returns with 0, how can I make it go back to the start of the func? Link to comment Share on other sites More sharing options...
Solution JohnOne Posted February 15, 2014 Solution Share Posted February 15, 2014 It already does. While 1 $search = _imagesearch('finish.bmp', 0, $x, $y, 0) If $Search = 1 Then Mousemove($x, $y,10) ExitLoop EndIf If $Search = 0 Then Sleep(5000) EndIf WEnd 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...
SBrix Posted February 15, 2014 Author Share Posted February 15, 2014 Thanks. I figured it out and it works now Link to comment Share on other sites More sharing options...
TrickyDeath Posted August 19, 2014 Share Posted August 19, 2014 (edited) You can use Window handle to close the process instead of clicking on X button to be closed. It is much better, since as i see you do not use mousecoordmode in your script, so, if the window posicion is change somehow, it will click on worng posicion. Edit: Also better cause, if anything pop up on that area, it will get active and will hide your X button, so it will click on the stuff what was pop up. BTW dont know if you are still watching this forum. Edited August 19, 2014 by TrickyDeath Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) 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