• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Determine screen number of active document

Contributor ,
May 30, 2023 May 30, 2023

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.

Views

128

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 30, 2023 May 30, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 30, 2023 May 30, 2023

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]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 05, 2023 Jun 05, 2023

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines