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

[JS, CS4] Document window resizing

New Here ,
Aug 08, 2010 Aug 08, 2010

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

TOPICS
Scripting
949
Translate
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

correct answers 1 Correct answer

Engaged , Aug 08, 2010 Aug 08, 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

Translate
Engaged ,
Aug 08, 2010 Aug 08, 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

Translate
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
LEGEND ,
Aug 08, 2010 Aug 08, 2010

Are you using the application frame?

That changes the behavior...

Harbs

Translate
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
New Here ,
Aug 08, 2010 Aug 08, 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?

Translate
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
LEGEND ,
Aug 08, 2010 Aug 08, 2010

Window > Application Frame

It was introduced in CS4...

Harbs

Translate
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
New Here ,
Aug 08, 2010 Aug 08, 2010

Ah, I understand what you mean now, Harbs. No, I turned off the application feature.

Translate
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
Engaged ,
Aug 08, 2010 Aug 08, 2010

Don't know why, your code seemed very similar to mine

Paul, its your code.

I have just added one condition

if (win.bounds != top+ "," + left +  "," + bottom + "," + right)

if window bounds not equal to which one you want then below code execute

win.bounds = [top, left, bottom, right];

else nothing change with window bound.

Shonky

Translate
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
New Here ,
Aug 08, 2010 Aug 08, 2010
LATEST

Shonky, it's true that you added one condition, but it seems odd to me that when you tell InDesign to make the doc window a size that it already is, it maximises the doc window. That's kinda weird!!! You'd think it would just put the doc window at the size requested by the script, as it did with CS3 and earlier. -- Anyway, thanks for sorting it out.

Translate
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