MACRO: Floating Progress Bar (Custom HTML Prompt) v1.5

This is AWESOME!

I've had learning Custom HTML prompt on my Someday List in my ThIngs ToDo Apps for almost a year. This may be the kick I need to get started!

1 Like

Hey Dan, another great macro! Thanks for sharing.

As an alternative to setting each of the JSON parameters in a separate KM Action, I'd like to offer this single Action to set all parameters:

ACTION: Set All Parameters for Progress Bar

Set All Parameters for Progress Bar.kmactions (959 B)
NOTE: When this ACTION is imported it will be auto-inserted into the Macro currently selected in the KM Editor app, after the Action that is currently selected.

My Custom Settings

  1. Window Title is set to the name of the Macro which called the Progress Bar
  2. The Window will be positioned at the current Mouse location
    • This can be easily improved to center around Mouse,:
      • MOUSEX() - 150
      • MOUSEY() - 75
    • OR center on active, frontmost screen.
    • The default is to center on MAIN screen, which may NOT be the front most screen.
  3. Cancel Button is enabled
  4. You need to change the "CancelMacroUUID" value to your Macro UUID

One Request

Change your HTML Prompt code to ignore a Parameter if its value starts with "TBD".

This would allow us to leave those Parameters in the JSON for future reference and ease of change.



Dan, thanks for providing the "Cancel Button".

Enhancement Request

However, rather than calling a specific Macro that is unique to the Parent Macro that called the Progress Bar, I would like to have an option to "Force Quit" the Panent Macro.

This can be done using the Cancel a Specific Macro Action.

The use case for this is a runaway script in the Parent Macro, or even a KM Action block that contains some Action that is hung up, not responding.

Here's an example:

I would like to have one macro that is always called by all Progress Bars when the Cancel button is pressed.
To make this work, I need to pass the following parameters to this general Cancel Progress Bar:

  1. Name of the Parent Macro that called the Progress Bar
  2. `%ExecutingInstance% of the Parent Macro, which could be assigned to a Progress Bar JSON field.
  3. Name of Global Variable to set to flag cancellation.
    • This would all us to create a unique variable for each Parent Macro.
    • Even better would be to use an Instance Variable, but I'm not sure that is possible given the process flow of Parent Macro > Progress Bar HTML Prompt > Cancel Progress Bar macro
    • @peternlewis, could this be done with Instance variable?

Thanks again Dan.

I came across that post yesterday, so I know exactly what you're talking about. :grinning_face_with_smiling_eyes:

It turns out that you can achieve what you want by setting CancelMacroParam to %ExecutingInstance%.

Then you can have a general-purpose macro that uses %TriggerValue% to know what instance to kill.

If I release a new version, I'll include this in the examples and/or Help file.


Just released version 1.3, which you can download from the first post. See the changes notes there.

This release was a lot of work, so please let me know if I broke anything. Obviously I don't think I broke anything, but after a while my brain started to fuzz over, so you never know.


Hey Dan, just got around to updating to Ver 1.3, and I'm getting this error:


I did delete the Macro Group and all macros of Ver 1.2 before I imported Ver 1.3.

How do I fix?


Just to make sure, I did it again:

  1. Delete Progress Bar MG and all macros
  2. Reload KM and KME
  3. Import from KM menu

Same error.


This looks like a JavaScript error in your HTML file for the "Show" macro.

Don't know why you're getting that error. Try right-clicking on the window, "Inspect", and view the Console to see if it reports any errors.

Hi Dan,

Right-clicking on the window yields this:


Does not show any errors, nor did I expect it to. The Safari JavaScript window just shows the HTML of the window. I've never seen an error reported here. Only when running a script in the debugger do you see an error.

I'm running Keyboard Maestro 9.2 on macOS 10.14.6 (Mojave).
Ver 1.2 worked fine. I'll reload it an test again.

@DanThomas , Ver 1.2 works just fine:


The tabs across the top - one of them should be "Console".

Sorry, I should have seen that. Here is the error reported:

[Error] SyntaxError: Unexpected token '?'
	(anonymous function) (Keyboard-Maestro-Custom-Prompt-13F1FD7D-3DD8-4FFF-947C-42A7177B2D1A.html:217)
[Log] ProgressBar_Params: {"CancelMacroParam":"3B480DF9-EF1B-4E2C-8CFE-20B174125F78:5D8E1703-614A-4279-AC45-D72CE11E2EDA","CancelMacroUUID":"A73C2D03-D0E0-4F38-8B74-FD9953BDE508","Max":"100","Text":"Example 2","Value":"0"} (Keyboard-Maestro-Custom-Prompt-13F1FD7D-3DD8-4FFF-947C-42A7177B2D1A.html, line 168)
[Log] Error in 'KMWindow': (Keyboard-Maestro-Custom-Prompt-13F1FD7D-3DD8-4FFF-947C-42A7177B2D1A.html, line 202)
Can't find variable: validateParams
> Selected Element
< <body>ā€¦</body>

And here's the problem line:
(shown by clicking on the function shown at the top of the above error report)

Does that help?

I forgot to ask - do you get this error when you run any of the "Example" macros? If you don't get the error in the Example macros, then it might be the parameters you're passing (maybe I have a big handling them). Let me know.

Otherwise, the error doesn't make any sense to me, because the use of ?? has been around a long time. And since nobody else has reported this error, it makes me wonder what's different on your system.

However, you can try changing the line to this:

var value = params[name];
if (!value)
    value = "";

Although I doubt it'll make a difference, since the problem is probably actually caused by something else.

I get the same error on all of your examples, except #1

I changed it to use the || operator, and it worked:

I've never used the ?? operator, but use the || all the time.

Can I change all of those to ||?

So I have no idea why ?? won't work.
I'm running macOS 10.14.6 (Mojave). What OS are you on?

I'm running Safari 14.1 (14611. on macOS 10.14.6 (Mojave).

and I have pending update for:

Could be something in Safari. When I get a chance later tonight/tomorrow, I'll make the update an see if that fixes it.

I'm using Catalina. According to MDN, Safari added support for ?? in version 13.1. Nullish coalescing operator (??) - JavaScript | MDN.

Looks like your change accomplishes about the same thing, so go for it.

Well, I don't know, but the update did NOT fix the issue.
Now running Safari 14.1.1 (14611. on macOS 10.14.6 (Mojave).

But when I change all of the ?? to || it works fine.
Is there some specific reason you used '??`

Anyone else running Mojave also running Ver 1.3 of Dan's macro?

That works fine in normal Safari, but NOT in the KM HTML Prompt, which uses the webkit:


I recommend you change your code to use || to ensure higher compatibility with macOS prior to Catalina.

Thanks, Jim. I uploaded a new version (1.4) that addresses this. If you get a chance, can you check it out and make sure it solves the problem? Thanks!

1 Like

Thanks for the quick fix, Dan. It works fine.
Running Keyboard Maestro 9.2 on macOS 10.14.6 (Mojave).
Safari 14.1.1 (14611.

But everyone should note that the webkit used by KM HTML Prompt does NOT fully support the same JavaScript as normal Safari.

@peternlewis , I don't suppose there is anything you can do about this?


Issue -- Using the ESC Key

Hey, Dan, question about using the "Cancel" feature.
It seems to be working as described when clicking on the "Cancel" button.
But when I press ESC, the standard shortcut to cancel, it immediately cancels everything: The Progress Bar and the Macro that showed it.
It did not invoke the "Cancel" Macro like it does when you click on the Cancel button.

I don't know if that is by design or not, but to me, the intuitive expected behavior is for the ESC key to work just like a click on the Cancel button.

Can that be done?