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

MACRO: Progress Bar v1.4

ProgressBar

NEW VERSION 1.5

UPGRADE INSTRUCTIONS

Delete the previous Progress Bar macro group before installing this version. Then everything will continue to work as before. Don't forget to re-enable the group if needed, after importing.

CHANGES IN v1.5:

  • No breaking changes.
  • If you have the Cancel Button visible, and the Progress Bar window is focused, pressing Escape does the same thing as clicking the Cancel button.

CHANGES IN v1.4:

  • No breaking changes.
  • Changed the HTML Prompt so it was compatible with some earlier versions of macOS.

CHANGES IN v1.3:

  • No breaking changes.
  • Added macro [Progress Bar] Utility: Setup Parameters (Prompt) which allows you to generate all the JSON parameters in one string, so you can assign them like this:
    image
  • You can now click on the Cancel Button even if the Progress Bar window isn't focused.
  • Changed macro Example 4: Cancel Button and Example 4a: "Cancel Button" Macro to use %ExecutingInstance% to kill the running macro.
  • Hardened up some of the error handling.

CHANGES IN v1.2:

  • No breaking changes.
  • Now comes in a .ZIP file, and the Help has been moved into the file Progress Bar Help.rtfd. Just double click it to view it.
  • New CancelButtonDisabled parameter can be set to 1 to disable the Cancel button, 0 to re-enable it.
  • New CancelButtonText parameter can be used to change the text from "Cancel" to something else.
  • New CancelButtonColor can be set to "blue", "white", or "yellow" (default).

PRIOR VERSION 1.1

BREAKING CHANGES:

  • The parameter "Title" is now called "Text".
  • The parameter "Text" is now "SubText".

NEW FEATURES:

  • Help file (macro).
  • Cancel Button.
  • New "Title" parameter lets you set the title bar caption.

Progress Bar Macros.v1.5.zip (430.2 KB)

PURPOSE:

Display a Progress Bar window:
image

With an optional custom title:
image

And some detail text:
image

And optionally a Cancel button:
image

USAGE:

There's example macros in the package. Let me know if you have questions, then I'll update this section as needed.

INSTALLATION:

  1. If you have a prior version installed, delete it first. In other words, delete the "Progress Bar" macro group.
  2. Download the .ZIP file (above).
  3. Unzip the .ZIP file.
  4. The help file is "Progress Bar Help.rtfd".
  5. Double-click the file .kmmacros to load it into KM.
  6. It will create a group called "Progress Bar".
  7. You'll need to "enable" the group.
  8. Check out the examples.
15 Likes

If it turns out that people are interested in this, I'll probably add options to change the window caption (it defaults to "Please Wait" right now), and add a Cancel button.

But as of the time I'm writing this post, nobody's downloaded it, so perhaps I was wrong about this filling a need. Still, it was fun to write and I learned some more about HTML/CSS and Custom HTML Prompts. Also, I have a use for it, so it's not wasted time.

Hi @DanThomas, great stuff, downloaded it yesterday,
questions about how to use it:

  1. Do I place "[Progress Bar] Step 1: Show" at the beginning of the macro?
  2. As for "[Progress Bar] Step 2: Update" do I place it inside the For Each action?
  3. If I leave the "Use with parameter" field empty or don't use it, I assume it defaults to 100, as a percentage is that correct?

Thanks! Glad to answer questions, and fix anything that doesn't work right.

  1. Do I place "[Progress Bar] Step 1: Show" at the beginning of the macro?

Yes. Assuming that's when you want the progress bar to show.

  1. As for "[Progress Bar] Step 2: Update" do I place it inside the For Each action?

Yes, passing the next Value you want it to be.

  1. If I leave the "Use with parameter" field empty or don't use it, I assume it defaults to 100, as a percentage is that correct?

If you're talking about the "Show" macro, then that's not correct. If you don't include "Max" and "Value", the progress bar becomes "indeterminate", which means it's like it's at 100%, except it has a little bit of an animation to it.

If you're talking about the "Update" macro, you have to pass something to it. There'd be no point in calling it if you didn't give it something to update.

Regarding the Max of 100, normally you'd set it be the number of steps you expect to do, so you can increment "Value" by one when you finish (or start) each step. But you're free to do whatever you want with it, including have it go backwards, or reset to zero, or even go "indeterminate" for a time if you want.

cool, thanks!

what I forgot to check was to move these:

image
inside the If Then

looks like it's working :slight_smile:

That's great to know. Let me know if you've got issues, and also if you have any thoughts on how I should document it better. But only if you want to - no worries otherwise. :grinning_face_with_smiling_eyes:

1 Like

Thanks for this, Dan! I plan to make good use of it…

FYI, I just uploaded a new version (1.1), which will most likely be the last version unless someone finds a bug. You can download it from the first post.

Most importantly, it includes a "Cancel" button. See the "Breaking Changes" comment in the first post - don't worry, there aren't a lot of breaking changes.

3 Likes

Hi @DanThomas - this looks like a great and very useful macro set! Thanks.

I was just playing around with it and ran into a problem. I ran Example 4 but clicking the Cancel button didn't do anything - the progress bar just kept cycling up and down.

I checked the UUID of Cancel Button macro and that seems to be in order so I'm not sure what's going on.

SOLVED: - I forgot to enable the macro group. Once I did that everything worked great!

That's funny - I happened to just sit down to the computer and see your message, and while I was typing a reply, I saw your "Solved" response.

Do I remember correctly that KM imports the group disabled? Let me know, because if so, I'll update the installation instructions.

1 Like

Yes, the import leaves the group disabled!

1 Like

@DanThomas just one question:
When comparing the parameter number with the Max number, does it hide even if it exceeds the Max number?

i.e. If I don't know the exact number of times it'll loop, say I put "Max 3000", but the times it really looped were 3100.

Edit: Ah never mind, the action is set to close the window, great thinking! :100:

Yeah, the progress bar max and value aren't related to anything else. You have to close it yourself. You could even restart the count if you wanted to, or set both Max and Value to blank (try it and see what happens sometime).

1 Like

Thanks for this, Dan. I only needed an indeterminant progress bar for Mirror Mirror Macro, so I made a lightweight variant that conforms to that macro's color scheme.

One thing that concerns me is the size of the Keyboard Maestro macro file (plist and sync). In Why Is the Keyboard Maestro Macro Editor Slow & Laggy?, Peter wrote:

The editor is designed for a relatively small set of macros (<1000), a relatively small macro file (<2MB), and relatively small macros (<20 actions). This is the typical usage. It is not designed to scale arbitrarily to unlimited size, any more than Notes is designed to write your next novel in.

When I added this macro group (which I realize can be pared down quite a bit after you learn how to use the progress bar), my Keyboard Maestro file grew to 3.4-MB from 1.1-MB.

I'm not sure how important a <2-MB Keyboard Maestro file is, but I'm afraid to find out. :sweat_smile:

The size is because of the help macro. Feel free to delete it. If you want to save the help, paste it into TextEdit and save it.

Contrary to what I said above, I have one more release coming, so I'll put the Help into a PDF. That way it won't get loaded with the macros. Thanks for the heads up.

Yep, I have found that is best to minimize the use of images stored within a macro.
KM stores all images as TIFF format I think, which really bloats the monolithic master macro plist file.

1 Like

New version 1.2 (which is now a .ZIP file) is in the first post.

Changes are listed in the first post, also.

Barring any bugs, I expect this to be the last update. Famous last words.

2 Likes

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