Query about "Display text in a window" function

I would like to (irrespective of the app which is foremost, but will be Mail, nvAlt, Word, whatever):

  1. Display some text (with Display text in a window), and while this continued to be present and not dismissed

  2. Prompt for User Input

  3. And for the result of selecting an option

  4. Go to one or more If Then Else, and paste certain text.

  5. Then dismiss the Display text in a window automatically.

  6. to 4. are not a problem. 5. is the problem as I cannot find the function to automatically bring it into focus and then dismiss it. Is this possible and how can I do it?

Any help would be gratefully received.

Picture of relevant part of macro:

and macro itself: Boilerplate for emails.kmmacros (28.3 KB)

Display Text in Window is an async operation - that is, it displays the text in a window and then the window is forgotten about and the macro moves on. Basically the same as Display Text Briefly which puts up a notification in Notification Center. So there is no way to close the window afterwards except by UI actions. So you could do something like finding the window on the screen and clicking there, but it’s pretty messy.

An alternative (fairly ugly I admit) would be to use the Custom HTML Prompt to display the text. Execute that asynchronously in another macro (using Executer Macro asynchronously) and so it would stay on the screen and the both macros would continue to run. When your primary macro finished, finish with the blunt instrument of Cancel All Macros which would cancel the second macro and remove the custom HTML prompt window. Not pretty, but it would work.

The only other alternative I can think of would be something that involved some other application displaying the text. Perhaps AppleScript? or you could open the text as a file in TextEdit and quit TextEdit when done.

Peter, I assume these windows belong to Keyboard Maestro Engine. Maybe a future version of KM could allow for storing a handle to each window in a KM variable, and then have a KM Action (or AppleScript command) that could manipulate the window.

Correct. It knows about the windows, but that information is not available to macros.

Anything is possible, but I can't imagine any UI for that that is likely to ever be implemented.

There is a place for a scriptable UI system, that lets you construct UI elements like windows with things in them and control and interact with them, but I'm not sure Keyboard Maestro is that place.

Peter,

Thank you for the detailed explanation.

In the end, I used Keyboard Maestro open Text Edit to display the text and then resize and move the window, and then quit that application.

Could in put your explanation in the online help for Keyboard Maestro (to help users understand the limitations of Display text in a window function)?