Jump to content

Recommended Posts

Posted

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?

Posted

@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]

Posted

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

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
  • Recently Browsing   0 members

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