Feature Request: Display Text Window Auto Close

Hi @peternlewis,

Is it possible to add an option to set an auto-close time for the Display Text window?
I could use the Custom HTML window, but I may have different number of variables to display and use different font styles. It is not very convenient. The Display Text window is the best option in most of the cases. An "auto-close" timer would be perfect.
Thanks!

Thanks!

3 Likes

I don't know how difficult this would be to add, but I would definitely find this extremely useful, especially now that Growl is basically dead and macOS' built-in notifications are still mostly terrible and not as good as Growl was.

You'd expect it to be pretty straightforward – many Keyboard Maestro Actions have a time-out property.

In any case – this can be done now.

Open the Display Text Window and Get its ID:

tell application "Keyboard Maestro Engine"
   set frontWindowID to id of front window
end tell

Pause for as long as desired and then close it.

tell application "Keyboard Maestro Engine"
   close window id frontWindowID
end tell

I'd probably call an asynchronous sub-macro timer and pass it the Duration and Window ID.

-Chris

3 Likes

There will be a native way to do this in the next major version.

11 Likes

This is a great news! Looking forward to the new version!!
Thank you so much!

1 Like

Hoping for the same for "display large text" :slight_smile:

The Display Large Text already has a configurable length of time for the display.

See the Set Action Delay action.

2 Likes

Is this in v10? Or did you mean a version after 10? If it's in 10, I can't find it.

thx;
-rob.

This was in version 9.

Use the Set Action Delay to set the time for the following Display Large Text actions.

image

Generally you should only ever use the “for this macro” option.

Oh, my mistake—I thought you were replying about the request for an auto-close on the Display Text in a window window. That's what I was trying to figure out how to do.

-rob.

No, there is no way to do that. You could probably use the LastWindowID token and the features related to it.

Hi Peter,

In July 2021 you referred to the "the next major version" in answer to the OP's question about automatically closing a Display Text in Window window, not Display Large Text.

The conversation then took a side track onto Display Large Text and Set Action Delay. So, when you recently said,

I got confused which display method you were talking about, and which version.

Does v10 have the feature the OP asked about, or are we waiting until v11?

Thanks.

In 10, you can use:

image

or

image

4 Likes

@peternlewis, or anyone...

Is %LastWIndowID% the only way of referring to Text Display windows?

They don't appear in the Windows menu, I don't seem to be able to access them with other KBM variables/tokens, nor with AppleScript. Where I can cycle through Chrome windows by clicking the Chrome icon in the Task Bar, doing that with KBM does not work. But it could be my ignorance.

Also, if I'm going to save the %LastWindowID% for a text display window, is there a way to have the timer for that run in the background, while the rest of my macro runs or I do other things like copy text from the window? If I have Large Text display, it pops up and the macro continue to do things while the display timer runs. That's how I can have multiple Large Text displays stacked on top of each other.

The only way I've found to run a KBM action asynchronously, like to wait to close a Text Display Window, is to invoke it from a Shell command line. Is there a better way?

No, presumably you can also reference them via AppleScript.

AppleScript seems to work for me:

I'm afraid I do not understand what you mean. What timer? For auto closing? Presumably you could use the Execute a Macro action, executing it asynchronously, pass it the %LastWindowID% and then it could simply pause for a while and then close the window.

Yes, Execute a Macro can run asynchronously. There are lots of other ways to run macros asynchronously (Trigger Macros by Hot Key for example).

Here's a subroutine that displays text in a window that will auto-close after a user-defined interval:

Display Text in Window - Auto-Close (Sub-).kmmacros (22 KB)

Macro screenshot

You can call it with an action group like this one:

Display Text in Window and Auto-Close.kmactions (1.7 KB)

Screenshot

Excellent!

I searched the manual/wiki for "asynchronous" and the only reference I found was in the Shell Command Line page. However, my wife will confirm that my skills at finding things that are right in front of me can sometimes be limited.

1 Like

Thanks! Yes, that's exactly the kind of thing I was imagining.

However, I wanted the window up for 30 seconds or so, long enough to examine it and compare with other windows, maybe copy some text. Yet I want it to autoclose because I might take that copied text to another desktop and paste it somewhere, and forget to go back, and I don't want numerous Text Display WIndows hanging around, cluttering my desktops and confusing me.

But running it a subroutine, the main thread waits for the subroutine to return, which is why I was asking about running it asynchronously.

Yes, I'm an idiot. Here you go:

Display Text in Window - Auto-Close.kmmacros (40 KB)

Macro screenshot

Display Text in Window and Auto-Close.kmactions (1.6 KB)

Screenshot

1 Like

You probably already know this, but you can also close all text display windows like this:

tell application "Keyboard Maestro Engine"
	close (every window whose name does not contain "Keyboard Maestro Editor")
end tell

I know this isn't the same thing as what you're asking for, but it's also very handy.