MrSWABE Posted February 5, 2011 Posted February 5, 2011 i have my first script made but i dont know how to add pause and continue button. can you help me add pause and contiue to this? ; ; AutoIt Version: 3.0 ; Language: English ; Platform: Win9x/NT ; Author: Jonathan Bennett (jon@hiddensoft.com) ; ; Script Function: ; Opens Notepad ; ; Run Notepad Run("notepad.exe") ; Wait for the Notepad become active - it is titled "Untitled - Notepad" on English systems WinWaitActive("Untitled - Notepad") ; Now that the Notepad window is active type some text Send("1") Sleep(250) Send("2") Sleep(80) Send("3") Sleep(50) Send("1") Sleep(250) Send("2") Sleep(80)
zanthal Posted February 5, 2011 Posted February 5, 2011 (edited) Forgive me MrSWABE, no intention of hijacking your thread, but my question is almost identical to yours so I figured I would ask it here and whatever Auto-it Guru answers yours can answer mine as well. I'm running a very simple infinitely looping script utilizing only the Send and Sleep functions. I need to know if there is a snippet of code or a function that allows for a currently running script to be toggled on/off with a specific assigned hotkey. Thank you Edited February 5, 2011 by zanthal
MrSWABE Posted February 5, 2011 Author Posted February 5, 2011 its ok for me..all i want is somebody reply to this thread and help us.
somdcomputerguy Posted February 5, 2011 Posted February 5, 2011 See the example here, http://www.autoitscript.com/autoit3/docs/functions/HotKeySet.htm, for one way to do it. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Dana Posted February 5, 2011 Posted February 5, 2011 MrSWABE, MsgBox(0, "Pause", "Click OK to continue") zanthal, #include <Misc.au3> HotKeySet("A", "myfunc") (your code here) myfunc() Func myfunc() While 1 If _IsPressed(41) Then ExitLoop Sleep(50) WEnd EndFunc
MrSWABE Posted February 5, 2011 Author Posted February 5, 2011 MrSWABE, MsgBox(0, "Pause", "Click OK to continue") can you lend me an example sir where can i put this? if i press my pause button on my keyboard does it appears this message?
zanthal Posted February 5, 2011 Posted February 5, 2011 MrSWABE, MsgBox(0, "Pause", "Click OK to continue") zanthal, #include <Misc.au3> HotKeySet("A", "myfunc") (your code here) myfunc() Func myfunc() While 1 If _IsPressed(41) Then ExitLoop Sleep(50) WEnd EndFunc Thank you Dana that would have cooked my brain trying to do on my own.
MrSWABE Posted February 5, 2011 Author Posted February 5, 2011 anyone knows how to use dana`s say? i mean, how can i use it?
czardas Posted February 5, 2011 Posted February 5, 2011 You should check out HotKeySet in the help file. I have modified the example slightly as an illustration. Read my comments (in green) carefully, as they explain what each part of the code is doing. Don't forget to press escape to exit the script when you have finished. Local $Paused ; Declare this variable, which a flag to indicate the current status - paused or NOT paused. HotKeySet("{PAUSE}", "TogglePause") ; Call a function to interrupt the script (press pause again to resume). HotKeySet("{ESC}", "Terminate") ; Call a function to exit the script. ; Start of Example Script. Replace this example with your own code. While 1 ; Repeat the following two lines until the script is interrupted or terminated. Sleep(3000) MsgBox(0, "Test", "This is a message!") ; Sends a message every 3 seconds. WEnd ; End of Example Script ; Function to pause and resume. Func TogglePause() $Paused = NOT $Paused ; Set the paused flag. While $Paused ; Do nothing until the paused flag is reset. WEnd EndFunc ; Function to stop the script. Func Terminate() Exit EndFunc operator64 ArrayWorkshop
Dana Posted February 5, 2011 Posted February 5, 2011 (edited) can you lend me an example sir where can i put this? if i press my pause button on my keyboard does it appears this message? Oh, sorry... I thought you wanted the program to pause itself and resume when you click OK in the message box. What I gave zanthal is more what you want, except it uses the "A" key. Here it will work with pause instead: #include <Misc.au3> HotKeySet("{PAUSE}", "myfunc") (your code here) myfunc() Func myfunc() While 1 If _IsPressed(13) Then ExitLoop Sleep(50) WEnd EndFunc If you press the PAUSE key while the "your code here" portion is executing, it will jump to the myfunc function and just loop doing nothing until you press PAUSE again. Edited February 5, 2011 by Dana
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