Copy link to clipboard
Copied
I'm using this code to center a window:
var win = new Window("palette",'MyWindow:', [$.screens[0].right/2 - 253,$.screens[0].bottom/2 - 127, $.screens[0].right/2 + 253, $.screens[0].bottom/2 + 127]);
That will work if the active document is on monitor 1 ($.screens[0]), but if it is on monitor 2 or 3, it will show my window on monitor 1.
Is there a way to query what monitor (screen) the active document is using?
Thanks in advance.
Copy link to clipboard
Copied
Figured it out. Slightly different code and I can't verify since I don't have dual monitors right now, but ...
Replacing $.screens[0].bottom with app.ScreenHeight or doc.ScreenHeight and replacing @$.screens[0].right with app.ScreenWidth or doc.ScreenWidth should center it on either the window that FrameMaker is on, or the window that the active document is on - which might not be the same thing.
Copy link to clipboard
Copied
The above assumes your window is roughly 506W x 254H - otherwise, you have to change the constants also.
easiest for me was using the normal window bounds until it looked correct and then taking the differences - i.e.
var win = new Window("palette",'MyWindow:', [15, 45, 525, 300]); // bounds = [left, top, right, bottom]
Copy link to clipboard
Copied
Above code does NOT work on dual monitors - it still shows on Monitor 1. - Worse, I think it takes the display resolution from the FM screen and applies to to Monitor 1. - for example, if Monitor 1 was 640x480 and monitor 2 is 1920x1200, and FM is on Monitor 2, it will display off-screen or in the bottom right of Monitor 1.