Sign in to follow this  
Followers 0
El Glyndo

Cancelling a script

6 posts in this topic

Hi, I', completely new to script writing, but I've written a small one that automates a copying and pasting function that I have to hundreds of times a day.

I need to know if there is a way I can cancel the script while it is running. Is that possible?

Share this post


Link to post
Share on other sites



@El Glyndo,

Welcome to the forums.

Like AutoItKing said, you can use code like:

HotKeySet("{ESC}", "_MyExit")

;your code goes here

Func _MyExit()
    Exit
EndFunc   ;==>_MyExit
...but where I placed "your code goes here" just make sure that none of your code sends the escape key or your script will end at that point. If you need to send the escape key to some other application, then just pick a different key to use as the "HotKey".

Also, the help file states:

AutoIt normally creates a tray icon when running, and right-clicking this icon allows the user to pause or exit the script.

Although a regular single left click does the same thing... (This assumes that your script allows you time to move the mouse to that icon.)

@AutoItKing,

One small change:

HotKeySet("{ESC}", "_MyExit")


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks for that guys, makes it a lot easier to use the HotKey. The script doesn't allow the mouse to be used by me so I'm glad that HotKey worked!

Once again, many thanks

Share this post


Link to post
Share on other sites

AutoIt also has a built in hot key to exit if I'm not mistaken. I believe it's the escape key?


http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]

Share this post


Link to post
Share on other sites

AutoIt also has a built in hot key to exit if I'm not mistaken. I believe it's the escape key?

Leaning something new everyday ...

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0