3 Replies Latest reply: Jul 7, 2007 6:06 AM by John_Nolan-ylAnVM RSS

    Is there a script to position document windows?

    John_Nolan-ylAnVM Community Member
      I think it's likely that someone (Dave?) has written a script for this, but I can't find one.

      I want to open (or at least reposition) document windows on my second monitor, not under the open panels on the primary display on my MacBook screen; and I'd like to find a way of doing this with keystrokes.

      If a script doesn't exist, is it possible, or is there some roadblock? Should I post in the scripting forum?
        • 1. Re: Is there a script to position document windows?
          This script I use all the time to set the ID document to the right window:

          Tell application "Adobe InDesign CS3"
          activate
          Tell active window
          maximize
          set bounds to {-173, 1283, 1146,3060}
          end tell
          end tell

          You will probably have to reset the bounds. To do this, set up the ID window in the screen sizing how you want it to be then run this script:

          tell application "Adobe InDesign CS3"
          get properties of active window
          end tell

          The new measurements will display in the result window in Script Editor, so have that open when you run the script. Then copy them into the first script array.

          It's quite easy - once you know!!

          HTH

          Oz
          • 2. Re: Is there a script to position document windows?
            Community Member
            I have indeed written such a script, but it is not aware of second monitors, and off the top of my head, I'm not sure how to make it aware.

            Ah, it doesn't have to be aware. The bounds are relative to the total monitor space. So my script will work.

            Here you go:

            //DESCRIPTION: Resets active window size or uses front window to set default size.
            

            // 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[(myParts.length - 1)] =  "WindowDefault" + app.version.slice(0,1) + ".txt";
            myNewPath = myParts.join("/");

            mySettingsFile = File(myNewPath);

            // Before proceeding, check that there is a front window
            // If not, offer user the chance to delete the current settings
            if (app.windows.length < 1) {
            beep();
            if (confirm("No window is open; would you like to delete the settings file?")) {
              // User said yes; check that it exists
              if(mySettingsFile.exists) {
               mySettingsFile.remove();
              }
            }
            } else {

            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 {
              beep();
              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();
              }
            }
            }
            Before you run the script for the first time, position a window where you want this script to position all subsequent windows. It keeps the information in a text file in the same folder as the script. You can reset the position by editing the file (that's what I often do to fine tune the position) or by running the script again with no window open.

            Dave
            • 3. Re: Is there a script to position document windows?
              John_Nolan-ylAnVM Community Member
              Thanks, guys. That's great! The text file is a very nice touch, Dave.