🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15985

Re: CS Palettes, Workspaces and Document Windows

#15985
From: Dave_Saunders
Date: Thu, 30 Oct 2003 13:27
53 lines
2704 bytes
Here's my script. I keep it in a folder names "Windows" in my Scripts folders (one for InDesign and one for InCopy -- it is possible to use aliases to run the same script from either, but I find that I need different default window sizes in the two apps, so I keep two copies in two folders so that they can each work with their own settings).

The settings file is kept in the same folder with the script. If the script doesn't find the defaults file, it'll make a new one based on the current front document, after first checking with the user.

Just copy and paste this with a text editor into a file named "ResetWindowSize.js" in your Windows folder in your Scripts folder. Oh, and for perfect bliss, give it a keyboard shortcut. I use Control-W on my Mac.

if (app.windows.length < 1) {
 exit();
}

// Check for WindowDefault.txt
// if present use it to set front window
// if not, use front window to set it
// after checking with user.

myPath = app.activeScript;
myParts = myPath.toString().split("/");
myParts[-1] = "WindowDefault.txt";
myNewPath = stitchString(myParts,"/");

mySettingsFile = File(myNewPath);

if (mySettingsFile.open("r")) {

savedBounds = mySettingsFile.read();
 mySettingsFile.close();

myBounds = savedBounds.split(",");
 for (i = 0; i<myBounds.length; i++) {
  myBounds[i] = Number(myBounds[i]);
 }
 app.windows[0].bounds = myBounds;
} else {
 if (confirm("Settings file is missing. Use current front window to set default?")) {
  // User said: go to it.
  new File(mySettingsFile);
  mySettingsFile.open("w");
  mySettingsFile.write(app.windows[0].bounds);
  mySettingsFile.close();
 }
}

function stitchString(theSubs,theSep) {
 var theStitched = "";
 for (var i=0; i<theSubs.length - 1; i++) {
  theStitched = theStitched + theSubs[i] + theSep;
 }
 return (theStitched + theSubs[-1]);
}

Apologies to people who see this more than once. I'm cross posting to all the relevant forums.

Dave
Technical Details
Message-ID: <2cce1175.0@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2cce1175.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,11e6f4ac0199b62e,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-10-30 05:37:48 PST
From: Dave_Saunders@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: CS Palettes, Workspaces and Document Windows
Message-ID: <2cce1175.0@webx.la2eafNXanI>
Date: Thu, 30 Oct 2003 05:27:05 -0800
References: <2cce1175.-1@webx.la2eafNXanI>
Lines: 63
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit