Countdown Using Keyboard Maestro’s Progress Bar

Howdy folks,

There are several countdown macros on the forum already, but I didn’t see any that make use of Keyboard Maestro’s progress bar action (though I might have just missed them if there are). This one uses that action to display the countdown, updating both the text and colored bar in real-time.

More details, screenshots and screen recordings are below. As usual, feel free to share any comments or suggestions, or to let me know if it doesn’t work for you.

NOTE: Version 2.0.0 is a greatly improved method, consisting of several macros that are part of a group. Version 1 is still available however in the Downloads section below.

-Chris

Downloads (click to expand/collapse)

Version 2.0.0: Countdown Macros.kmmacros (62.3 KB)

Version 1.0.0: 47)[MG-SUBRT] Show countdown using progress bar.kmmacros (20 KB)

CURRENT VERSION: 2.0.0 (Tuesday, July 23, 2024)

Version History

v2.0.0 Tuesday, July 23, 2024
Completely new macro, designed as a subroutine that enables an independent macro that is executed every second until the subroutine cancels it, or the countdown runs out.
Various other improvements as well, such as displaying a message in the countdown window and sending Pushover notifications.
See notes in macros for more information.

v1.0.0 Friday, July 28, 2023
Initial macro

Screen recordings (click to expand/collapse)

countdown

Macro screenshots (click to expand/collapse)






RELEASE NOTES, INSTRUCTIONS AND DISCLAIMER

Purpose of this macro (click to expand/collapse)

Display a countdown timer using Keyboard Maestro’s progress bar action

How this macro works (click to expand/collapse)

A calling macro (for instance, the Toggle or Stop macros) send all relevant information to the subroutine, which calculates the countdown and starts or stops a progress bar.

How to configure this macro (click to expand/collapse)

Update (or delete) the Pushover actions in the Subroutine, supplying your own user and token strings.
You may also want to change the position of the progress bar in the Subroutine.
By default it is the top right corner of either the main or secondary screen.

How to use this macro (click to expand/collapse)

You can use the Toggle macro to manually set the countdown each time, or embed the Caller macro into your existing macros to have the countdown start or stop automatically if needed.
For the Caller macro, just input the pertinent details in each field.

Disclaimer (click to expand/collapse)

TL;DR: I built it and it works for me. You can share/modify it how you want. But don't blame me if it doesn’t work for you :laughing:

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

4 Likes

Beautiful - now if we could change the color of the window =), but really, nice macro and very useful for me, I've used others but I like this the best so far.

Is there somewhere to trigger a sound and/or a screen 'blink/blinking' at the end of the time?
Ah...
I could put something after the 'clear progress bar' in the sub-routine. Would you suggest any other place? That seems to make sense.

1 Like

Thanks for the kind words!

I didn’t add that capability as of yet, but I like the idea and may do that in the future.

That is likely the best place for that kind of feature to. :+1:t2:

Do you think using this timer is taxing the system at all?

I highly doubt it. The macro is not that complex, and even on my newer version (which consists of a calling macro and subroutine), running continuously I see no change to CPU usage in Activity Monitor when it’s running versus when it’s not running.

1 Like

Last suggestion, maybe a variable could be added in the title that could tell the user what the timer is for. So the title would show time remaining and then some text. Just a thought, bro no biggie.

1 Like

Ok so your comments here made me realize I had completely changed (improved) this macro quite some time ago, but never shared the new version. :sweat_smile:

Version 2.0.0 is now available, with the changes you mentioned (as well as others), and is linked in my original post above. Check it out and let me know your thoughts when you get a moment!

2 Likes

V2 keeps stopping, I've searched all my macros and eliminated the old, cancel all macros that I used in the beginning of my KM learning, I don't believe I even triggered any macros and it stopped counting down... (of course I probably did, but am not aware)

EDIT: I definitely did not trigger any macros after it started, and it stopped on it's own, most times after 30-50 seconds of the count down it stops.

EDIT: I started it, didn't do anything at all, and it stopped 22 seconds 'down' from the start. It's done that now 2 times in a row at exactly 9:38 it stops. I'm usually starting with 5 or 10 minutes as the countdown.

Can you check the KM Engine log and tell me what it says when the macro stops? Also, when it stops, is the subroutine enabled or disabled?

Well, the previous stopping I reported was happening on one of my work machines.
On the work machine that is stopping.
The sub-routine is not still running when it stops and there is no error in the engine log

Something I'll mention about the work machine stopping.
I run the MBU macro 3 times a day. It must have run while this issue was going on with the stopwatch because MBU was sending me an email every second (like it was on the seconds schedule of the stopwatch). Is it possible it got crossed up somehow with the stopwatch? It was very weird.

However on one of my home machines the stopping does not happen. (Until more testing - see below)
But I do get the following about the periodic reminder
"2024-07-23 20:10:47 missing token, missing user. Macro “08)Countdown: KM progress bar (subroutine) (for export)” cancelled (while executing Send Pushover Notification)."

Also, I noticed while I was remotely logged into the work machine from home.
I started a timer on my home machine and after 5-10 seconds I saw a timer show up on my work machine and then is closed after a few seconds.

Erg, and now, the home machine is stopping also at 9:38!
And I also get this error
"2024-07-23 20:24:48 missing token, missing user. Macro “08)Countdown: KM progress bar (subroutine) (for export)” cancelled (while executing Send Pushover Notification)."

EDIT: The same weirdness. I have a macro that runs once an hour to check it there is more than 1 KMSync file and sends an email, 1 email, if there is. I just got like 30 emails sent every second. And there were as many 'conflicting KM sync files'
Something is really wrong going on here.... sorry to say.
I'm going to disable the macro group on all my machines for the time being.

Well if you run KM on multiple machines, then you need some way to ensure this macro only runs on one of those, otherwise it will cause problems. For now, enable the macro group on only one of the computers and test it again.

As for the “missing token” errors, that’s the Pushover action. I mention in the release notes that the user needs to either supply their own user and token strings or delete those actions. Try disabling them for now and test again.

1 Like

Any thoughts on the stopping? And it getting caught up with 2 other macros?

I’ll run without the periodic reminder and check.

Could be that it’s trying to run on both computers, but only one has the necessary variables (whichever one set them up when it called the subroutine), and when it runs into an action that uses a variable that doesn’t exist, it cancels or errors out.

No idea, but I don’t see why my macros would interfere with those. The only theory is MBU is detecting the change in the subroutine’s enabled state and creating another backup, and the sync file is getting duplicated because of the same change.

Make sure to completely disable the Pushover actions for now; otherwise it may cause problems at the end of the countdown when it tries to send a final notification.

1 Like

MBU isn't that sophisticated :). It normally only runs manually, but even if Troy put it on a periodic timer, that's still the only time it would run. When it runs, it exports all the macros, then does all its work (on a database created from) that exported file; it has no idea what's going on within Keyboard Maestro.

Whatever's going on is very strange.

-rob.

2 Likes

Argh, you’re right, I realize now my comment wasn’t very clear. In my personal copy of MBU (which I’ve tinkered with haha) I have some steps to cancel the backup if the only changes to my library involve a list of specific macros. I do this to prevent backups from running unnecessarily when the only change may have been a macro’s name changing, or enabled state changing. I shouldn’t post before my morning coffee has worked it’s magic haha.

@troy if you’re still having trouble, try temporarily disabling the other two macros in question and run the countdown again and report back.

2 Likes

Can this be modified so that I can do testing without dis-abling the MBU macro?

Yes, in that you can add the action I have included below to cancel the backup if the only macro modifications made since the last backup were to specific macros. Make sure to replace the UUID strings with whatever they are for your copies of the Countdown caller and Countdown subroutine.

If you want to try it, add this at the beginning of your MBU macro.

NOTE: this won’t work the first time because you don’t have the global variable Backups__Most Recent Modification Timestamp set yet, but the next time it runs via the periodic or idle triggers (or if you just manually execute the actions nested in the if action), then it will set the variable and the next time it will work.

Cancel if no recent macro modifications.kmactions (5.8 KB)

Action Screenshot (click to expand/collapse)

1 Like

ah, the MBU only runs on 1 machine, and I will never use the stopwatch on that machine. So no need, correct?
And the stopwatch will run on all other separate machines as I designate them.
Sorry for the work if so...

nice so far!, I modified the pushover to be an sms to my phone if needed. Running only on 1 machine so far, no stops, no errors, 'periodic notification' working.

What a great and very useful macro man, ! serious...

I'll keep using it as testing for a couple days ...

cheers

1 Like

Hey, without taking a deep dive, I've put one of Dan's great display messages at the end right after you close the progess bar action. That display has it's own placement parameters but they are being ignored and positioning where the progress bar is designated to be.
Any simple clue? =)
Thought you might know quicker than me digging around....
thanx man