kyoder17 Posted May 25, 2011 Share Posted May 25, 2011 so i am new to this and trying to write a script to test a robot arm. this is basically going to be a test of the arm so its just going to run through the loop tike twenty to fifty times, but in case something goes wrong i need to be able to stop it anyone have any advice here is what i have so far #include <GUIConstantsEx.au3> $count=1 $position=200 Do MouseClick("left", 800, 300, 1) MouseClick("left", 850, 325, 1) MouseClick("left", 550, 300, 1) Send ( "{BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE}" ) Send ( "{BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE}" ) Send ( "{BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} " ) MouseClick("left", 550, 300, 1) Send ( $position,1 ) MouseClick("left", 600, 300, 1) Sleep ( 5000 ) MouseClick("left", 550, 300, 1) Send ( "{BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE}" ) Send ( "{BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE}" ) Send ( "{BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} 252" ) MouseClick("left", 600, 300, 1) Sleep ( 5000 ) MouseClick("left", 850, 300, 1) MouseClick("left", 800, 325, 1) Sleep ( 1500 ) $count=$count+1 GUICreate("End Loop", 200, 100) GUICtrlCreateLabel("Click to End", 30, 10) $continuebutton = GUICtrlCreateButton("Continue", 70, 50, 60) $endbutton = GUICtrlCreateButton("End", 10, 50, 60) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg(5) $msg2 = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $endbutton $count=4 ExitLoop Case $msg = $continuebutton ExitLoop Case $msg = $GUI_EVENT_CLOSE ExitLoop ExitLoop EndSelect WEnd Until $count=4 the point of the script is to click on a program we have and then enter values as needed to move the arm up and down. thanks in advance for any help you can give. Link to comment Share on other sites More sharing options...
bogQ Posted May 25, 2011 Share Posted May 25, 2011 i suggest that you exit the script with hotkey HotKeySet() TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
kaotkbliss Posted May 25, 2011 Share Posted May 25, 2011 (edited) HotKeySet() will let you create a function that will interrupt the script. Either pause or kill or both or do something else... *edit* doh, paused too long. Bog beat me Edited May 25, 2011 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 25, 2011 Moderators Share Posted May 25, 2011 (edited) kyoder17,Welcome to the AutoIt forum. The simplest method is to use a HotKey. Add this to the top of your script:HotKeySet("{ESC}", "On_Exit") Func On_Exit() Exit EndFuncNow whenever you press ESCAPE the script will stop immediately. On another matter, your While...WEnd loop could do with a bit of a tidy: $hGUI = GUICreate("End Loop", 200, 100) GUICtrlCreateLabel("Click to End", 30, 10) $continuebutton = GUICtrlCreateButton("Continue", 70, 50, 60) $endbutton = GUICtrlCreateButton("End", 10, 50, 60) GUISetState(@SW_SHOW) While 1 ; Only one call needed $msg = GUIGetMsg() Select Case $msg = $endbutton ; Just exit immediately - no need to increase the count Exit Case $msg = $continuebutton ; Delete the GUI GUIDelete($hGUI) ExitLoop Case $msg = $GUI_EVENT_CLOSE ; Again just exit directly Exit EndSelect WEndPlease ask if you have any questions. M23Edit: Slower but more comprehensive! Edited May 25, 2011 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
GEOSoft Posted May 25, 2011 Share Posted May 25, 2011 Another tip for you. Instead of Send ( "{BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE} {BACKSPACE}" );send backspace 6 times try Send ( "{BACKSPACE 6}");; Send backspace 6 times. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
kyoder17 Posted May 26, 2011 Author Share Posted May 26, 2011 Thanks everyone for the help this is exactly what i needed, i had been trying to set hotkeys but just doing it wrong. 2nd Question is there a way to exit the GUI i created with the end or continue button auto matically, by this i mean is there a way to have it continue if there is no input for like thirty seconds. I tried initaiting a wait comand at the end but that paused the whole GUI and made it so no inputs would be accepted. Again thanks for any help you may be able to give, here is the code for the pop up window $hGUI=GUICreate("End Loop", 200, 100) GUICtrlCreateLabel("Click to End", 30, 10) $continuebutton = GUICtrlCreateButton("Continue", 70, 50, 60) $endbutton = GUICtrlCreateButton("End", 10, 50, 60) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $endbutton Exit Case $msg = $continuebutton GUIDelete($hGUI) ExitLoop Case $msg = $GUI_EVENT_CLOSE ExitLoop ExitLoop EndSelect WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 26, 2011 Moderators Share Posted May 26, 2011 kyoder17,Use TimerInit and TimerDiff like this: #include <GUIConstantsEx.au3> $hGUI = GUICreate("End Loop", 200, 100) GUICtrlCreateLabel("Click to End", 30, 10) $continuebutton = GUICtrlCreateButton("Continue", 70, 50, 60) $endbutton = GUICtrlCreateButton("End", 10, 50, 60) GUISetState(@SW_SHOW) $iBegin = TimerInit() While 1 $msg = GUIGetMsg() Select Case $msg = $endbutton Exit Case $msg = $continuebutton GUIDelete($hGUI) ExitLoop Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect If TimerDiff($iBegin) > 5000 Then ; If we have waited more than 5 secs Exit EndIf WEndM23P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
kyoder17 Posted May 26, 2011 Author Share Posted May 26, 2011 Again i must thank you for your help. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 26, 2011 Moderators Share Posted May 26, 2011 kyoder17, My pleasure. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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