Progress Bars

I have macro that converts / processes PDF files from images to text.

I use OCRmyPDF to do so and noticed that the conversion can take time.

I was concerned that the macro was hanging so added a progress bar that looks like this:

I noticed that the progress bar is of fixed size, and a limited number of characters.

I was able to get the progress bar to bounce back and forth while the conversion is taking place by entering -1 in the progress field and then close the progress bar once the conversion had completed by entering 100 in the progress field as follows (where the shell script is the PDF → text conversion):

Is there a way to get the progress bar to display a different message (i..e, PDF text conversion complete!) and hang around for a second before disappearing?

While I know I can do this through notifications I prefer the idea of a process bar because it is front and centre.


And, while on the topic of progress bars I decided to experiment with HTML and had Gemini (I know nothing about HTML) build the below custom progress bar:

<!DOCTYPE html>
<html>
<head>
    <style>
        body { 
            background-color: #1e1e1e; color: #ffffff; 
            font-family: -apple-system, BlinkMacSystemFont, sans-serif;
            margin: 0; padding: 12px 20px; text-align: center; overflow: hidden;
            border: 1px solid #444; border-radius: 8px;
            display: flex; flex-direction: column; justify-content: center;
        }
        .text { font-size: 14px; line-height: 1.2; margin-bottom: 8px; }
        .sub { color: #aaa; font-size: 11px; display: block; margin-top: 2px; }
        .loader {
            height: 4px; width: 100%; background: #333;
            border-radius: 10px; overflow: hidden; position: relative;
        }
        .loader::after {
            content: ""; position: absolute; left: -50%; height: 100%; width: 50%;
            background: #007aff; border-radius: 10px;
            animation: loading 1.5s infinite linear;
        }
        @keyframes loading { 0% { left: -50%; } 100% { left: 100%; } }
    </style>
</head>
<body data-kmwindow="SCREEN(Main,Left,calc(50% - 300)),SCREEN(Main,Top,calc(50% - 45)),600,90">
    <div class="text">
        pdftotext / OCRmyPDF text conversion in process, standby.<br>
        <span class="sub">This window will close when complete.</span>
    </div>
    <div class="loader"></div>
</body>
</html>

The problems with the custom progress bar are:

  1. The extra black area as highlighted in red that appears as part of / with the custom progress bar and teh shape, I would like it to be rectangular. Is there a way to do so as no amount of asking Gemini or CharGPT was able to do so?

  2. While I have yet to do so -- and apologies for being lazy on this point -- how do I control / manage the custom HTML prompt. I will run the HTML prompt asynchronously so that the rest of the instance can run, but why action do I place after the PDF → text conversion to close the custom HTML prompt?

Thank you.

To have the progress bar linger with an updated message you can simply end your macro in this way:

Or for something a little more fancy:

1 Like

Appreciate but that will get what I am after because at 100% the progress disappears, teh completion message will never be displayed, I tried it.

Thanks.

Yes, and at any value below 100, it displays. In both my examples above the progress bar is displayed with a value of 99, for 1 second, before disappearing.

Try it out, and you'll see.

Your full macro example would look something like this, using the simplest of my two examples above

1 Like

The "Display Progress" Action spawns the progress dialog if it doesn't already exist -- if it does exist it will update the dialog's "Title" and "Progress" to the values in the Action. (And yes, that means you can only have one "Display Progress" dialog at any moment.)

So to do what you want just change the second "Display Progress" to Progress: 99 so the dialog displays with an almost-full bar, add a 1 second "Pause", and a final "Display Progress" with Progress: 100 to clear the dialog.

That's what @Alexander's examples are doing, in two different ways.

1 Like

@Alexander and @Nige_S

Apologies for being careless and obtuse, I should have read Alexander's initial response more closely as I missed the point about placing it at the "end of your macro in this way".

Of course, what is being suggested is both elegant and what I was looking for. I went the "fancy route", works great!

Much thanks to both!

1 Like

I noticed the erroneous alert in the action

Apparently searching does not search for the Display Progress Progress field, which means it does not find the variable used there.

Fixed for the next version.

2 Likes

Peter, appreciated.

I noticed this too -- including the message -- but disregarded it as the value was being used in the loop.

Thank you for clarifying.

1 Like

Hello @Joel :waving_hand:

I saw your Vibe Coding Atempt above coding a custom Progress Bar.

Maybe you’re interested in this handy Macro by @DanThomas - even though it’s not supporting Darkmode:

Greetings from Germany :germany:

Tobias

Tobias, good evening.

I appreciate you thinking of me and passing along the macro.

I will certainly take a look and see whether it is better / worse than what I now have.

Thank you.

Joel