Skip to main content
Known Participant
August 8, 2010
Answered

[JS, CS4] Document window resizing

  • August 8, 2010
  • 2 replies
  • 981 views

Hello all

Having trouble re-sizing the main document window with the below script fragment. Used to work perfectly in CS3. In CS4, if the document window is maximised and then the script is run, it works: it makes the window smaller. If the doc window is smaller than the maximum size and the script is run, it maximises the doc window: it doesn't make it the size specified in the script. In other words, every second time the script is run it works; the other times, it maximises the doc window. Have tried using smaller values for the win size, but doesn't matter what the values are.

Any idea what's going wrong? It's a bit of an annoying glitch for me ...

===

const left = 0;  const top = 50; const right = 200; const bottom = 200;

win = doc.layoutWindows[0];

var bounds = win.bounds;
bounds[0] = top;   bounds[1] = left;   bounds[2] = bottom;   bounds[3] = right;
win.bounds = bounds;

===

I've tried making the above variable win point to app.activeWindow instead -- still doesn't work.

Hope someone can help...


Paul

This topic has been closed for replies.
Correct answer Shonkyin-CF145T

I have not any idea why InDesign changing size of windows on second time running on script.

Try below code, hope it will help you:

var doc = app.activeDocument
const left = 32;  const top = 105; const right = 1500; const bottom = 1500;
win = doc.layoutWindows[0];
if (win.bounds != top+ "," + left +  "," + bottom + "," + right)
{
win.bounds = [top, left, bottom, right];
}

Shonky

2 replies

Harbs.
Legend
August 8, 2010

Are you using the application frame?

That changes the behavior...

Harbs

PaulR72Author
Known Participant
August 8, 2010

Shonky -- thanks very much, your code worked. Don't know why, your code seemed very similar to mine -- but it worked.

Harbs. Sorry, I don't know what you mean by the application frame. I'm using a Mac, so I guess there's only a document frame, not an app one?

Harbs.
Legend
August 8, 2010

Window > Application Frame

It was introduced in CS4...

Harbs

Shonkyin-CF145TCorrect answer
Inspiring
August 8, 2010

I have not any idea why InDesign changing size of windows on second time running on script.

Try below code, hope it will help you:

var doc = app.activeDocument
const left = 32;  const top = 105; const right = 1500; const bottom = 1500;
win = doc.layoutWindows[0];
if (win.bounds != top+ "," + left +  "," + bottom + "," + right)
{
win.bounds = [top, left, bottom, right];
}

Shonky