ErkanA Posted August 17, 2016 Share Posted August 17, 2016 Hello, I am a bit new to AutoIT, written the following script but I want to pause/resume when I click on mouse click but I want to pause instantly. expandcollapse popup#include <AutoItConstants.au3> Global $Paused HotKeySet("^!w","pause") HotKeySet("^!s","start") $Paused = False While 1 = 1 If $Paused = False Then Send ("{4 DOWN}") Sleep (1500) Send ("{4 UP}") Sleep(200) Send("3") Sleep(200) Send("2") Sleep(200) Send("{SHIFTDOWN}") Sleep(50) MouseClick("LEFT") Sleep(100) MouseClick("RIGHT") Send("{SHIFTUP}") Else Sleep(5000) EndIf Wend Func pause() $Paused = True EndFunc Func start() $Paused = False EndFunc Any help is appriciated Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 17, 2016 Moderators Share Posted August 17, 2016 As you only check $Paused at the top of your If loop, it is going to go through all of those steps before checking again - thus it will never be "instant". If you want it instant you would either have to check the value of $Paused after every step or look at AdLibRegister. On a wider note, what are you trying to accomplish? Using a bunch of Sends and Sleeps is not going to be very consistent; depending on what you're trying to do there is probably a much better way. "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...
Xandy Posted August 17, 2016 Share Posted August 17, 2016 (edited) Add this chunk right after the While 1 = 1 If _IsPressed(1) Then; Left Mouse Button While _IsPressed(1) Sleep(20) WEnd If $Paused = True Then $Paused = False Else $Paused= True EndIf EndIf; _IsPressed(1) You'll also need to include <Misc.au3> at the top where you're including things. Edited August 17, 2016 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Bert Posted August 17, 2016 Share Posted August 17, 2016 also - using "send" is EXTREMELY BAD. Look at ControlSend The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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