Jump to content

tools: stop executing command


sbrady
 Share

Recommended Posts

what does it mean when the "Tools>stop executing" menu item is hightlighted. Does it mean that something is still running in your script.

I have a GUI with 6 Tabs and up to 6 buttons on any tab. Some buttons are not fully programmed, yet they do something simple as opening a Message Box that says "You pushed button 4". Shouldnt the script stop after that simple command. What is going on that makes the "Tools>stop executing" menu item active.

Link to comment
Share on other sites

  • Moderators

sbrady,

If the <Tools - Stop Executing> menu item in SciTE is highlighted (highlit?) then your script is still running. :)

The script will only stop if it comes across an "Exit" command or if the script flow ceases - this shows you what happens:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$cButton_1 = GUICtrlCreateButton("One", 10, 10, 80, 30)
$cButton_2 = GUICtrlCreateButton("Two", 10, 110, 80, 30)
$cButton_3 = GUICtrlCreateButton("Three", 10, 210, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ; Exit the script directly
            Exit
        Case $cButton_1
            MsgBox(0, "Button 1 Pressed", "This will exit because it is followed by 'Exit'")
            ; Exit the script directly
            Exit
        Case $cButton_2
            MsgBox(0, "Button 2 Pressed", "This will exit because the script flow stops")
            ; Break out of the While...WEnd loop
            ExitLoop
        Case $cButton_3
            MsgBox(0, "Button 3 Pressed", "This will NOT exit because it just re-enters the loop")
            ; The script continues in the loop waiting for the next event
    EndSwitch

WEnd

; Button 2 ends up here and the script exits as the script flow ceases

All clear? :)

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

  • Moderators

sbrady,

That is what will happen when the script stops. ;)

they do something simple as opening a Message Box that says "You pushed button 4". Shouldnt the script stop after that simple command

What do you want to happen after the MsgBox is closed? :huh:

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

I would expect the script to be in a state of doing nothing. I dont understand why the MsgBox command makes the script wait for something else to happen. When I make a directory, its OK, when I open a folder, its OK, why is this making the script seem like its waiting for more.

Link to comment
Share on other sites

  • Moderators

sbrady,

The script is always doing something until it exits so the menu item remains highlighted. At a absolute minimum it is staying active to look for the next event - that is why we always need some form of loop (usually a While...WEnd loop enclosing a GUIGetMsg or a Sleep command) within the script. Otherwise we get to the end of the script flow and it just stops - as you saw from the above example. :)

The script pauses when a MsgBox appears because the MsgBox is created by a call to the Windows API. This is a blocking call and the script waits to see what it gets as a return value when the MsgBox is closed. If you want to have the script continue and ignore any action the user takes then you might want to look at Yashied's NotifyBox UDF as an alternative. ;)

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...