Cannot control display where Custom HTML Prompt is appearing

I have two displays—the iMac (which is the "Main" display) and an external. In my web search macro, if a user opens the help page, what they get onscreen is two windows: Help and the shortcut input box.

The help page is in a custom HTML prompt window (built by a series of variables that store raw HTML), and the shortcut input box is just a standard Prompt for User Input. If I'm working on my second display and launch my macro, the input box appears there, as I'd expect. If I then ask to see the help, though, it opens on the main display.

Why does this window open on the main display, and is there any way to force it to open (or to to move it to) the display with the input prompt?

thanks;
-rob.

Have a look at this, it may be of help: action:Set Next Engine Window Position [Keyboard Maestro Wiki]

Rob as a good answer, and it may be the right solution for you.

But also remember that you can control this from inside the Custom HTML Prompt. In your KMWindow() function, you can return a string with the position and size, like

function KMWindow() {
    return "300,200,600,400";
}

or

function KMWindow() {
    return "SCREEN(Second,Left,20%),SCREEN(Second,Top,20%),420,560";
}

You could also add something like this to the "body" element:

<body data-kmwindow="SCREEN(Second,Left,20%),SCREEN(Second,Top,20%),420,560">

I have this already in the body tag of the HTML:

<body data-kmwindowid="thehelpwindow" data-kmwindow="ROUND((SCREENVISIBLE(FRONT,Width)/2)-420),ROUND(SCREENVISIBLE(FRONT,MidY)-200)+8,840,420">

But even if I hide all apps, move to my second display, open a Finder window, and invoke my macro, the Input dialog appears on display two, the help screen on display one. I don't want to specify a display, I'd like it to open (ideally) on the display with the mouse input dialog. But I tried using MOUSE as well as FRONT, still no change.

-rob.

Currect, that won't do what you want. You need to add SCREENVISIBLE(FRONT, LEFT) to the x coordinate, assuming your secondary screen is on the right. I just typed that from memory, so it may be wrong, but hopefully you get the idea. And I would think "MOUSE" should work.

It's very possible I'm totally misunderstanding kmwindow, but I thought it was saying "position this window at location FromLeft, FromTop at a size of Width and Height. How do you add a screen identifier to that structure? I searched the forum and wiki but didn't find anything that looked like it had two SCREEN calls in it. The end result has to be a value, doesn't it?

thanks;
-rob.

Turn on Window->Mouse Display in the editor. Move your cursor to the second screen. Watch the x-coordinate. Notice that for the secondary screen, it doesn't start at zero. So if you want to position something on that screen, you can see the kinds of numbers you have to specify. In other words, you have to add the left edge of the screen to your desired x-coordinate.

In other words, look at these two actions:

image

I guess I'm not explaining the issue clearly, so my fault :). I don't know where the Input dialog is going to appear. But when it appears, I need the help window to appear on that same display. And who knows how many displays someone has.

I think maybe I'm getting there with the Next Engine thing, which I could then translate to the tag, but I'm trying to figure out how to get it to appear exactly where I need it—I do now have it showing up on the right display, at least :).

-rob.

You need to know which screen the input dialog is on. If it's a standard KM action, then your best bet is to use Set Next Engine Window Position (or whatever it's called) to force it to a certain window, then you'll know where to put the help window.

If you'd rather try and determine where the Prompt window is, there's ways to try and do that, but they may not be all that reliable depending on things like palettes and the like, but it may be possible.

I force it to the frontmost display, and that part seems to be working. So while I don't know what display it's on, I do know it's on the frontmost display. I just want the help window to also go on that display.

-rob.

And me typing that keyed me in on the stupidity that is me. I use an AppleScript to force the input window (size and location), but I wasn't calling that script for my HTML prompt, just relying on the body tag.

I've now called the script, and it's for sure on the right window display; I just need to move it around a bit now.

Thanks for putting up with the questions!

-rob.

Then add SCREENVISIBLE(FRONT, Left) to your x-coordinates, and it should appear on the correct screen.

That's what I asked about earlier—how would that look in actual use form? I'm having trouble understanding how that fits into something that's supposed to be a number. (Though this is mainly for my knowledge in general, as the AppleScript is doing it's thing.)

And I thought I already had that: ROUND((SCREENVISIBLE(FRONT,Width)/2)-420)

-rob.

I might make a typo here, but hopefully it'll help:

kmwindow="SCREENVISIBLE(FRONT,Left) + ROUND((SCREENVISIBLE(FRONT,Width)/2)-420),ROUND(SCREENVISIBLE(FRONT,MidY)-200)+8,840,420">
1 Like

Hallelujah! That works great, thank you so much. And I think I now finally understand what you were trying to say. That calculation basically says "get the position of the left edge of the front display, and then add half the width less half the window I want to center."

On my Main display, the first bit evaluates to 0, but on the second, it starts at 2560.

Edit: It seems to handle any display arrangement, too—I just set my two displays in all sorts of weird layouts, and it always worked. Thank you SO much!

Thanks again!

-rob.

1 Like

Glad it's working. But you may have another problem. What if the user's screens are oriented vertically? So you need to do basically the same thing for the Y coordinate, if that makes sense.

Fortunately, you can change your screen's orientations and test things. But I'll tell you, when you set up your screen which is physically on the right to be logically on the left, or logically above your main screen, it can mess with your mind. :joy:

See my edit: I just did all that. Even with them stacked perfectly vertically, it worked fine. I do a lot of testing for our Moom app with monitor arrangements, and yea, it's a real brain issue getting the mouse to go where you think you need it to go!

-rob.

1 Like