Visible countdown timer for action timeout?

When an action (e.g. a "Prompt for User Input" dialog) has a timeout, is there a way to include a visual countdown of the time remaining, either within that dialog itself or maybe in the menu bar or somewhere else on screen?

I do not believe itā€™s possible to read out the set timeout value programmatically, but if it is an option for you to also type the set value as a parameter of an Execute Macro action you could have that asynchronously run a macro that displays a countdown. Personally Iā€™d use a Display progress displaying the countdown, but I guess it should also be possible in the menu bar. I am not by my Mac today, otherwise Iā€™d build a quick demonstration.

To have the Prompt for User Input dialogue itself display an updating value might be more tricky, (but might it maybe be possible by having it close and reopen (ā€œrefreshā€) every second?)

@peternlewis, this here reminds me of a question Iā€™ve been meaning to ask: Could it make sense to implement a way to set timeout options programmatically? For instance with something like a 'Set timeout for next action' action, or something like that?

Hey Alex

You would never need a dedicated action for this ā€¦

Use the Set Variable to Text or Set Variable to Calculation Action for the Value and execute the Prompt using either AppleScript or JXA.

Of course this could be done with every other action as well.

Greetings from Germany :de:

Tobias

Hello David (@anythingbutdave)

There will be no chance displaying the Timeout in the Prompt until you write it in HTML.

BUT - if you want to run an asynchronous Macro based on the Timeout Value you want - you could do that ā€¦ Iā€™ve already written about to @Alexander about how this will work.

Greetings from Germany :de:

Tobias

This sounds like a functioning workaround, but sadly I am a total novice when it comes to Java and AppleScript (and all other scripting languages), so I wouldnā€™t even know where to begin to display a prompt and set its timeout though these languages.

Itā€™d be cool if you could demonstrate how, but for me personally Iā€™d always prefer doing as much as possible without scripting

If you want to do things like changing Action Properties programmatically youā€™ll have to do scripting ā€¦ there is no other chance.

Danā€˜s Dynamic Prompt for User Input Macro is one possible way to do it as well but as youā€™ll read there it requires an additional Plugin that has to be installed first.

Also this Macro - while it is great and very Valuable only supports some Properties not all of the Action.

The Action Timeout Property is actually not supported. Iā€™m afraid - but it is totally worth it.

I am currently working on a Tutorial series based on the Scripting Topic where Iā€˜ll also show a way to introduce how to handle Plugins that arenā€™t installed via Scripting. But I canā€™t say when it will be online. It seems I donā€™t have much time for it at the moment. Too much other work to do.

Maybe Iā€™ll post an update to Dans Macro for all Properties that will also work for people who donā€™t want to install the Plugin , too.

Weā€˜ll see ā€¦

Greetings from Germany :de:

Tobias

1 Like

I have a new version that doesn't require anything additional. If anyone needs it, let me know.

But I don't think that will help in this situation, although you could probably at least set the timeout programmatically.

@anythingbutdave:

The best way I can think of to give a visual notification showing how much time is left, is to launch another macro asynchronously. This macro would display the Progress Bar, update its value in a loop with a Pause action, and close the progress bar when the time is up.

It would also monitor a global variable, that the original macro can set when it finishes without timing out. The Async macro would quit if that global variable gets set.

I can write an example of how to do this, but only if you need/want it. It's reasonably easy, but I don't want to spend time on it unless it's actually needed.

Hey Dan

Thanks for diving in ā€¦

It would be nice if you could post it in addition to the old one - and make it clear in the OP that the old one is an example for the required Plugin. Or make a new Topic.

But my wish is to keep the old one because itā€™s as of my knowledge the only Macro on the forum that uses the plugin. If you could support all possible Action Properties it would be great, too.

I think this is actually related to David (@anythingbutdave) if he needs the help on this ā€¦ I had this idea, too and I know exactly what youā€™re talking about - because I would do it exactly like you wrote it down here - but even though Iā€™m online and responding here and there - my time doesnā€™t allow this ā€¦

Have a nice day

Greetings from Germany :de:

Tobias

Got it - I edited my post to reference him.

Speaking of not having the time... I'm in the same boat. If I get a chance, I'll see what I can do, but don't hold your breath. :smile:

1 Like

Of course not :sunglasses:

Whew! Lots of replies! Thanks, allā€”I'm not in a place where I can dig into this today but will revisit the question ASAP. I really appreciate the suggestions!

Back by my computer now and here's a macro pair that displays a countdown, using the Display Progress action, that closes if the callers prompt is closed or canceled.

Just set the first parameter of the Execute a macro action (the value before the comma now set to 5) to what you've set your prompts Action Timeout to, and this should work.

Prompt For user input CALLER .kmmacros (16 KB)

Prompt For user input TIMEOUT COUNTDOWN SUBMACRO.kmmacros (18 KB)

Macro Images

EDIT: Moved the precautious pre-emtying of the global variable into the submacro instead

1 Like

I haven't take a look at what you've done, but did you figure out what to do if someone cancels the prompt? Will it still stop the timer? That's the one thing I wasn't sure about how to handle.

Yup, my solution to this is the condition of the Pause Until that checks if the text %ExecutingInstances% contains %TriggerValue[2]%. (The second parameter of the %TriggerValue% gets set to the callers instance ID using the %ExecutingInstance% in the Execute Macro action parameter field). Using this method the global variable isnā€™t even necessary if the caller macro does not contain any time consuming actions after the prompt.

2 Likes

Hello Alex

Nice solution thoughā€¦

I think youā€™ve missed the time out condition here.

Besides that - this is a solution that could only be used when you display information to the user.

If anyone wants to use something like that in a real environment with Options there is many more that has to be considered. And the loop will have to be set up quite different.

Greetings from Germany :de:

Tobias

I have some ideas for solving this, but I am on vacation. I may get to this later.

How? Or very open for the fact that Iā€™ve missed something, my approach relies on typing in the set timeout (5 seconds in my example). Is this what you mean?

Hey Alex

Actually itā€™s easier to see what Iā€™ve done than telling you. Iā€™ve made a couple changes.

This isnā€™t the Version I was talking about earlier with Variables and their Values but we are getting there.

PUI with Timeout Vers 2.kmmacros (54,5 KB)

Iā€™ll have to go to bed and sleep now ā€¦ itā€™s nearly 2 am in the morning here and Iā€™m awake for 20 hoursā€¦

Good night :sleeping: and greetings from Germany :de:

Tobias

1 Like