Controlling The Position of User-Prompt Windows on The Screen

When using the Prompt for User Input window (and related "show a window/alert" macros), I feel like the macro should offer some control over where it appears on screen. If there is a way to do this, I can't find it.

I know that Prompt for User Input opens the window in the same position the last time it appeared, so I can show it, position it where I want it, and it'll come back in the same spot, but I just wanted it centered horizontally by default, like a display alert in AppleScript.

1 Like

There is a way to do this besides using AppleScript, but it's not obvious or enabled by default. The easiest way I've found to do so with KM actions requires that an alias to the Keyboard Maestro Engine (found in the Keyboard Maestro app package at /Keyboard Maestro.app/Contents/MacOS/Keyboard Maestro Engine.app be added to the Applications folder. Once that's done, you can use KM's Manipulate a Window action to center KM prompts and alerts like this:

Center Keyboard Maestro Prompts and Alerts.kmmacros (2.0 KB)

(The settings I used are just a suggestion, though one I think looks pretty close to the AppleScript alert window position; you can of course set your own to whatever you like)

Once you have a macro like this set up how you like, all you need to do is run it while a KM prompt or alert from a different macro is displayed, and as you said, it should retain the position from then on.

All that aside, having a built-in setting for where KM prompts and alerts appear is a good idea; hopefully it'll make it into a future version.

7 Likes

This is cool, thanks! I didn't get it at first that you don't do this as a step in the macro where you want to center an alert/prompt, but rather as a separate macro you run once the alert/prompt from the other macro is already displayed. Clever.

But why does it need an alias to the KM Engine in the Applications folder to work? It seems to work fine for me without that alias in /Applications.

No problem! So the macro I uploaded worked fine for you without needing to make an alias to the KM engine? Interesting. I made an alias on my own machine some time ago, so I don't remember the exact circumstances, but my recollection is that it wasn't possible to select the KM engine from among the list of applications shown in the Manipulate a Window action unless it was present in the Applications folder. If it worked for you without the alias on yours, I can only presume you don't need the alias after all when using a macro made by someone else, at least if you and the macro's creator both have KM installed in your system Applications folder rather than your user one. If that's the case, then the only reason you would need the alias is if you tried to make your own window manipulation macro that targeted the KM engine from scratch, and you can safely ignore the instruction otherwise. At any rate, I'm glad the macro worked for you out of the box!

2 Likes

Works great. I didn't need to alias the KM engine either. Maybe in the past KM didn't allow selecting an application that was within another application bundle? In my tests I was able to drag the KM Engine in to KM to select it as an "Other" app to target by opening the KM app bundle in the Finder.

If anyone else ends up here, I found that putting the Execute Macro action right before the Alert action works well, set it to execute asynchronously and it seems to trigger just in time (at first I had tried making it more complicated by having the sub macro wait for the alert to appear, but it wasn't needed):
image

Would be nice to have the option built in though.

5 Likes

I have to say this is a great thread! Thanks to you all (@gglick, @gruber, @jon123) I've been able to position my prompts consistently at last.

Just one thing. I'm running an iMac with 2 screens and so when I use this technique the prompt always appears on the main screen - which is not always where the macro is initiated from. So I've modified the Center action as follows:

Now, when the action is called, the prompt appears as required, but on the same screen where the macro was originally triggered from.

I just re-read that and realised how hard it is to describe what's going on! I hope you get the idea, anyway - and thanks again!

1 Like

Yep, I made the same change.

1 Like

Is there any way to achieve similar results with palettes? I switch between a large-screened desktop and 13" Air—macros syncing between them—and centering a palette on one puts the same palette elsewhere on the other.