I want to show a page that floats in front of other windows that lists shortcuts for apps. Each app has different shortcuts so I want the shortcut list to show for only that app and only while that app is active. As soon as the app loses focus I would like the list to disappear.
I have made an HTML file that displays an image of the list of shortcuts and it works great to activate it when an app activates but I don't know how to automatically close it when the app loses focus. Is there a way to focus the html window and close it? I tried setting up a "click on found image" then escape when the app deactivates and sometimes that works and most of the time it doesn't so then if it doesn't close and I activate the app again it just keeps showing new html windows.
How can I close the html window when an app deactivates, or is there a better way to do this? I have tried with dialog boxes and Macro Group menus but the text is too small in them - or is there a way to change the text size in those?
I tried the While statement but that doesn't close the html window when the app loses focus. I assume it would work for macro palettes but as I said, the text is too small for me in the palettes. I want to see at a glance not have to stare at the palette and find the line I am looking for.
I'm sorry, I was playing around with the macro to see what works best and I uploaded the wrong one. I can't post another one until at least 6 hours because I'm a 'beginner'. Instead of the "Pause Until" I was using an "If/Else" statement:
If Swift Publisher is active show the HTML file, ELSE do the click on found image and ESCAPE
I also tried an Automator workflow where I recorded clicking the close button. That seems to work but it takes a long time for the mouse pointer to get over to it to click it, especially if my mouse is on the other monitor, the opposite side of the html window.
I guess I found a solution but if someone has more ideas I love to learn.
I didn't realize I could use a "Display Text" box and paste rich text into it so I designed a list in Pages with larger text and pasted it into the macro's "Display Text Box". I then close it with an Apple Script after the app loses focus. (FYI - I couldn't get the Apple Script to close the html window).
I tried the While statement but that just kept opening more text boxes while I was using the app. I had to unfocus the app in order to stop the text boxes from replicating.
If anyone is interested I can upload the macro I am using but it won't be able to be done for a few hours.
Thanks for the 'Text Box' tip. I would not of considered this. I see it would be very useful. KM can size and place it wherever I want it, and dismiss it when I'm finished with it.
"Display Text" windows are "Engine windows" and have their own items in the window selection popup of the various Window actions. Because you may want open other windows in the meantime it would be good to capture the ID of the window you want to keep open, then use that ID explicitly later on when you want to close it. This example does just that:
Note: I've used local variables because this is all in the same macro. If you want to share the ID between macros, use a global.
You can deal with Custom HTML prompts in the same, except this time you set the window ID as an HTML <body> attribute (if you were generating more than one window at a time from the same macro you'd need a way to make this unique fro every instance). I'm no JavaScripter, but a simple way to close what would appear to be an HTML form even when you put no form parts on it would be to fire the "Cancel" event, targeting our chosen Window ID: