Jump to content

terminate


Recommended Posts

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

i suggest that you exit the script with hotkey

HotKeySet()

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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

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 :huh2:

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

  • Moderators

kyoder17,

Welcome to the AutoIt forum. :huh2:

The simplest method is to use a HotKey. Add this to the top of your script:

HotKeySet("{ESC}", "On_Exit")
Func On_Exit()
    Exit
EndFunc

Now whenever you press ESCAPE the script will stop immediately. ;)

On another matter, your While...WEnd loop could do with a bit of a tidy: :ph34r:

$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
WEnd

Please ask if you have any questions. :alien:

M23

Edit: Slower but more comprehensive! :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

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

  • Moderators

kyoder17,

Use TimerInit and TimerDiff like this: :huh2:

#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

WEnd

M23

P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. ;)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

kyoder17,

My pleasure. :huh2:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...