I am trying to accomplish something simple. It would take me two minutes in QuicKeys and ten minutes in AppleScript (by using a third-party timer). I am a KM newbie, and I’m not using AppleScript to get more experience with KM.
Have user click a button whose title is the desired interval in minutes such as 10.
Save the doc.
Save the doc 10 minutes later.
Quit macro when doc is closed.
I’m having trouble passing the button selection to a variable.
I’m trying to use Pause Until inside the loop for waiting, I see no choice related to time interval. Do I have to capture the current time, add ten minutes, and do that for every loop?
Although you did not explicitly so state, I have assumed you want to auto-save EVERY N minutes. If this is incorrect, you will need to adjust the below macro.
I think this macro should do the job. Please test with TEST documents before you use in production. Let us know if this works for you.
####DOWNLOAD:
<a class="attachment" href="/uploads/default/original/2X/8/8db99104db89780bdeabf8cf6c7249837c0dc342.kmmacros">Auto-Save Document @Example.kmmacros</a> (9.5 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**
---
###ReleaseNotes
Author.@JMichaelTX
**NOTICE: This macro/script is just an _Example_**
* It is provided only for _educational purposes_, and may not be suitable for any specific purpose.
* It has had very limited testing.
* You need to test further before using in a production environment.
* It does not have extensive error checking/handling.
* It may not be complete. It is provided as an example to show you one approach to solving a problem.
**HOW TO USE**
1. Open a new or existing document in any app
* **App MUST have a File>Save menu item**
* Trigger this macro
* Macro will do an immediate File>Save and then pause for the entered Save Interval
* This Macro will EXIT whenever ANY of the following are true, even if the actual document is still open. The exit is NOT immediate, but after the last Save Interval.
1. The Title of the FrontWindow Has Changed
2. The FrontMost App has changed
* **This macro does NOT support concurrent executions as it is currently designed**
* If you trigger this macro again on a different document, it will wait in queue until the first instance of the macro has completed.
**MACRO SETUP**
* **Carefully review the Release Notes and the Macro Actions**
* Make sure you understand what the Macro will do.
* You are responsible for running the Macro, not me. 😉
.
* Assign a Trigger to this maro.
* Move this macro to a Macro Group that is only Active when you need this Macro.
* ENABLE this Macro.
.
* **REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:**
* ALL Actions that are shown in the magenta color
**USE AT YOUR OWN RISK**
* While I have given this limited testing, and to the best of my knowledge it will do no harm, I cannot guarantee it.
* If you have any doubts or questions:
* **Ask first**
* Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.
---
<img src="/uploads/default/original/2X/b/b996cf3d0e2b86fbb23abea9a6ec658ae8fa7832.png" width="530" height="1475">
Thank you for your quick response and your example. It did work, though I
want to learn enough to tweak it soit will meet all my wishes. Your macro
contained something I didn¹t even consider: Prevent simultaneous occurrence.