Edit Mode Script Run

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
winterswv
Newbie
Posts: 1
Joined: Fri May 06, 2016 11:57 am

Edit Mode Script Run

Post by winterswv » Fri May 06, 2016 12:01 pm

How do I stop a running script when in edit mode Shift-ESC does not work

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Edit Mode Script Run

Post by Marcus Tettmar » Sun May 08, 2016 9:22 pm

Works for me in edit mode. Also CTRL+F2 which you will see is the shortcut for "Stop Debug" under the Debug menu. The editor would have to be active for that. Then you can also hit the Stop button. But SHIFT+ESC is global. And works for me while in Edit mode. Which version are you on?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Edit Mode Script Run

Post by JRL » Mon May 09, 2016 1:19 pm

One caveate to this is that the script may not stop if it is stuck in a function call. For example if you're running a particularly intense VBScript or if you have a DBQuery> to a large data table, the script won't stop while running that process. If your intense function takes 60 seconds, and you have that intense function in a loop, you might have a millisecond long window every 60 seconds in which to press shift+esc and stop the script.

I try to always build in a Quit subroutine tied to the Esc key in a key_down OnEvent>. Place this code at the top of your script. When you need to stop, press the esc key.

Code: Select all

OnEvent>key_down,VK27,0,Quit
SRT>Quit
  Exit>0
END>Quit
The shift+exc combination is passed to the script and closes the script immediately. If the script doesn't close, shift+exc has to be pressed again since it acts on the script at the moment it is pressed. On the other hand, the OnEvent key press is built into the script, so pressing the esc key once is "remembered" because the Quit subroutine is inserted into the script's process sequence.

Bear in mind that if the script is busy running a particular function, the script will not quit until the function completes. If the function is in an infinite loop your only choice will be to start Task Manager and kill "msched.exe". If you do this you will lose any unsaved changes to your script.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts