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

:slight_smile:

Thanks for this great macro. I have a very long macro using it and it works quite well.
Now, as anybody trying to work with this kind of long macro, I often have to debug or fine tune one of the steps, and while the SubText parameter and the cancel parameter are great I think a way to pause things would be really useful.

The way I see it is if a Pause parameter is "on" the update macro would pause things and make a "Proceed" Button appear next to the cancel button.

I think it would make step by step debugging a bliss (well...yes...)

I have built a debugging system called Checkpoint for KM that includes pause/stop/continue as a feature (and much more besides). I am considering releasing it into the wild but… I will be posting about it soon. Sorry to be a tease!

2 Likes

First, don't forget that KM has a Macro Debugger, which might be what you want. With that said:

You can use the Cancel button for whatever you want. Just because it's called Cancel doesn't really mean anything. And in fact, with version 1.2, you can change the button text to something else.

So you can use that to come up with a way to pause and resume the main macro. Perhaps set a variable that the main macro checks periodically, and pauses (maybe show a Prompt).

Anyway, something like that.

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.
:+1:

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.

Thanks.

2 Likes

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%.
image

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

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

2 Likes

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.

4 Likes

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

image

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

How do I fix?

EDIT:

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.

EDIT 2:

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:

image

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:

image

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.1.21.161.7) 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.2.7.1.6) 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:

image

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