Hi,
Please give an example of a macro that would shut off an application in one hour.I don't want it to be a time trigger, but rather I want an amount of time to be a condition. That is, if one hour has passed, then quit the application.
You said "I want the amount of time to be a condition." Oh, I guess then I have to rewrite the above. The above will work, so I'm not sure why you want to make it more complicated (and less CPU-efficient.) But here's a version with "a condition," as you requested:
Thanks so much! That gives me a much clearer idea how to work with time-related macros. KM is wonderful, but for those of us who are not programmers, it's not always clear how to set things up.
You are welcome. Thanks for being nice. One of the tricky things with helping people is that they usually are asking for a specific solution and about half the time that approach is not always the best. So it's tricky because if you tell them about a different solution they may get defensive.
No, I'm always up for advice. I've been a supporter of KM since pretty much the beginning, but I am often confused on how to set up things which tokens and functions to use and so on. Not to impose on you too much, but could you point me in the direction of what commands to use if I wanted to display some kind of countdown display of the time elapsed either in the menu or on the screen as the Pause command counts?
Sure, I'll think about that. I have solved that myself a few times, in a few different ways. I can probably post one or two of my solutions below. This is still the same topic so it doesn't need a new post.
I usually use sound, not a display, to indicate a countdown. Sounds may not work for you, but it works for me, and it may work for some people, so I'll post an idea or two here:
The above code is something I use when I want to warn myself that if I don't stop the program it will start all over again. You may ask "where's the 30 second timeout?" It's actually in the cogwheel of the action, in the Set Action Timeout dialog box. Personally I wish these options were visible in the macro, but I think that the author of KM thought that they would be to rarely used to force it on everyone. But he already has an information for hiding rarely used information, those little triangles, so that's what I wish he would use for this feature. But I digress.
In the example above I have an audio countdown (which isn't always decrementing by one, but that hardly matters) and I allow the user to exit the loop by pressing the CTRL key.
Here's a really fun one that's visual instead of audible: (REALLY visual)
Again, it allows the user to cancel early with the CTRL key. It's actually hilarious. If you don't like it, I won't blame you. Make sure you use the "Large" option which is indicated above.
A slightly more respectable visual method might be this:
Super. There are other ways to display information, like in the status bar at the top of macOS, but that's a lot of work for very little benefit. When I think of another way to display feedback, I'll add it here.
It's generally best not to have long running macros, even one that is just a Pause. So my solution to this would be a macro that triggers on launch and records the time, and another macro that triggers periodically while the app is running, and checks if the run time is long enough, and if so quits it. For example:
Macro One: Trigger on App Launch
Action: Set variable App Launch Time to calculation SECONDS()
Macro Two: Trigger on App Running repeating every N minutes (use N of 1-5 probably).
Actions:
If calculation SECONDS() > App Launch Time + 60*60