Busturdust Posted June 25, 2015 Share Posted June 25, 2015 (edited) Hi all,New autoit scripter here. I have some things working right now as far as exiting process, stopping services, and editing registries.What I would like to do know is add a Cancel Button. The functionality of this cancel button should be to stop the running function, and theoretically undo every thing that it has done.I can most likely accomplish the "Undo" part on my own. However, I am trying to get the cancel button to hook up correctly, so that it first stops whatever is happening, and exits the application. Once I do this I will add int he revert logic between the "stop" and the "exit". My current script is attached. Thanks in advance! Edit Updated Attempt with flag in functions. Portus.au3 Edited June 25, 2015 by Busturdust Link to comment Share on other sites More sharing options...
MikahS Posted June 25, 2015 Share Posted June 25, 2015 Have a look at this tutorial from the AutoIt Wiki: Interrupting a running function Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
TheSaint Posted July 1, 2015 Share Posted July 1, 2015 @Busturdust - Welcome to the Forum.This question really belongs in General Help & Support or GUI Help, where it is sure to be seen by many more people, who can give you the help you need. It does not belong here, where the development of AutoIt and related issues are discussed.I will Report this topic so it can be relocated for you. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
TheSaint Posted July 1, 2015 Share Posted July 1, 2015 If you are struggling with that Wiki entry, then there are other options.Basically you need to have something running in the background that a function can interact with.I use different methods for this.[1] An ini or registry entry that is checked by every function regularly (i.e. every 500 ms). This involves using something like a floating STOP button or a key press, from a separate running executable, where a value is written to an INI file or the Registry.[2] Using the AdlibRegister function and button ID, with your functions checking on the state of a variable.With number [2], I generally use a START button that gets renamed to STOP when clicked, and the AdLib function call is started. I use a variable called $stop which is empty until the AdLib function assigns it a '1' after recognizing a specific button has been clicked, using the button ID, not handle. Each function that you want to be able to exit from, needs to keep checking the $stop variable to see if it is now '1', and then exits itself if it is. This can be a little tricky to set up, until you get the hang of it and understand what is happening. Having a STOP button be separate to a START button definitely helps, but uses more GUI space. Disabling the button after STOP is clicked so that you don't accidentally restart, is important.I find number [1] has a better response time and is more reliable.There may be other alternatives I've never looked into.P.S. My KindEbook Wishlist program uses number [2] process, but you may struggle extracting necessary code elements etc. It is also created with a much older version of AutoIt, and some function names etc have changed (i.e. AdlibEnable instead of AdlibRegister).. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now