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
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
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
Tobias
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.
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
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.
Of course not
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)
EDIT: Moved the precautious pre-emtying of the global variable into the submacro instead
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.
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
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 and greetings from Germany
Tobias