silly135 Posted April 15, 2013 Share Posted April 15, 2013 (edited) #include HotKeySet("{PAUSE}", "checkForImage") HotKeySet("{DEL}", "Terminate") global $y = 0, $x = 0 Func checkForImage() while 1 mousemove(960,600,10) Local $search = _ImageSearch('FEM.bmp', 1, $x, $y, 0) I f $search = 1 Then MouseMove($x, $y, 10) sleep(2000) EndIf wend EndFunc while 1 sleep(200) WEnd Func Terminate() while 1 sleep(200) wend EndFunc I want to add to this code and make it so that If $search returns 0 it continually searches for the image every 33ms for the next 2 seconds (time of the sleep after image is found) without having to repeat the code 60 times. Any help is much appreciated I looked into using TimerInit and TimmerDiff but couldn't get it to act quite as i wanted. Edited April 15, 2013 by silly135 Link to comment Share on other sites More sharing options...
JohnOne Posted April 15, 2013 Share Posted April 15, 2013 Here's what usually happens. People give a user suggestions and the user says "I already tried that", peoples time is wasted. So to avoid this, and as you are the one needing it, use your time to post everything you have tried so far. 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...
silly135 Posted April 15, 2013 Author Share Posted April 15, 2013 (edited) What I tried in the while loop: while 1 ... $begin = TimerInit() While 1 $dif = TimerDiff($begin) if $dif>2000 then exitloop Local $search = _Imagesearch('FEM.bmp',1,$x,$y,0) If $search =1 then exitloop wend wend The program doesn't give me an error, but it also doesn't run. When I check my task bar and task manager it isn't there. Edited April 15, 2013 by silly135 Link to comment Share on other sites More sharing options...
JohnOne Posted April 15, 2013 Share Posted April 15, 2013 Because there is no idle while loop to keep it alive, or a function called to actually start it. 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...
silly135 Posted April 15, 2013 Author Share Posted April 15, 2013 What do you mean by that? I'm pretty new to auto it and have been using working examples to structure my scripts so i don't understand some of the lingo. Link to comment Share on other sites More sharing options...
JohnOne Posted April 15, 2013 Share Posted April 15, 2013 #include HotKeySet("{PAUSE}", "checkForImage") HotKeySet("{DEL}", "Terminate") // script starts here, you need to keep it alive else it will just exit. global $y = 0, $x = 0 whilw 1 sleep(100) wend Func checkForImage() while 1 mousemove(960,600,10) Local $search = _ImageSearch('FEM.bmp', 1, $x, $y, 0) I f $search = 1 Then MouseMove($x, $y, 10) sleep(2000) EndIf wend EndFunc while 1 sleep(200) WEnd Func Terminate() while 1 sleep(200) wend EndFunc silly135 1 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...
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