Copy link to clipboard
Copied
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
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Are you using the application frame?
That changes the behavior...
Harbs
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Window > Application Frame
It was introduced in CS4...
Harbs
Copy link to clipboard
Copied
Ah, I understand what you mean now, Harbs. No, I turned off the application feature.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now