Macro is triggered by a hotkey, changes the volume by Python script and display current volume of Denon AVR in progress bar.
After delay of 2 sec I close the progress bar.
It works.
The issue occurs after repeated trigger, the last action closes the progress bar early then needed.
The question is how to prevent from the last action to be executed and prevent the closing of the progress bar when repeated trigger occurs?
The problem appears to be that you aren't treating the Progress Bar as a "shared resource." You have multiple copies of the macro running concurrently and the ones that ran first are cancelling the Progress Bar (via your last action) before the subsequent instances of the macro are finished.
There are probably several ways to solve this, and there will likely be multiple solutions offered to you.
My idea for solving this is to have the macro assign a value of "SECONDS()+2" to a global variable, (at the start of your macro) say, "SecondsToEndDisplay" and then instead of having a "Pause" action, use this instead:
If you follow this approach, all concurrent instances of your macro will wait until the global value of SecondsToEndDisplay is reached, causing all of them to end simultaneously.
I realize that I wrote my advice this "descriptive way" rather than uploading a macro for you. If you try to write the macro but can't succeed, let me know and I'll write it for you. I think with these tips, you should be able to write it yourself.
There will likely be other ideas from other people, but they won't get much simpler than this.
You are welcome. I occasionally do crossword puzzles, sudoku puzzles, chess puzzles, etc., but my favourite kind of puzzles are programming puzzles. This was a fun one.
Here's another solution that will close the dialog when only one instance of the macro remains running -- no global required. (I've used a random number to set the Progress bar so you can spot each execution as you do it and see that it's the last-set value that's displayed until the dialog is closed -- swap RAND(1,9) * 10 for your variable.)