8 Replies Latest reply on Oct 25, 2016 11:04 PM by Laubender

    Moving and Sizing the activeDocument Window?

    Bill McLean

      I have an scriptUI modal dialog that I position to the top left corner of the screen. I extend the height of the dialog to the height of the screen.

       

      I make the active document window full size with the following code:

       

      var myMenuAction = app.menuActions.item("$ID/Consolidate All Windows");

      myMenuAction.invoke();

       

      after turning off the application frame and controls.

       

      Setting the activeWindow bounds to the width of the dialog:

       

      app.activeWindow.bounds.left = 237;

       

      How to ensure that the main document window is sized and positioned?

        • 1. Re: Moving and Sizing the activeDocument Window?
          Laubender Adobe Community Professional & MVP

          Hi Bill,

          can you show some screenshots?
          I'm a bit unsure what you like to accomplish.

           

          As I understand your question:

          1. You want to use Application Bar instead of Application Frame

          2. You want to consolidate all floating layout windows

           

          What's not clear for me:
          You want to set the left bounds of the active window to the width of your modal window, that already has the maximum height and a destinct width ( 237 pixels ) ?

           

          If you are using a modal ScriptUI window wouldn't you be able to do anything with the layout windows?
          To change the layout windows' width you'd need a none-modal window of type "palette".

           

          Now to your code:

           

          app.menuActions.item("$ID/Consolidate All Windows").invoke();
          

           

          is not working with my German InDesign CS6 on Mac OSX 10.6.8. Error message: "Object is not valid".

          Instead I found the line I am showing below working for me. I called after app.findKeyStrings("Alle Fenster &zusammenführen")—the German menu command for "Consolidate All Windows"—and came up with:

           

          app.menuActions.item("$ID/kConsolidateAllDocumentsMenuItem").invoke();
          

           

          That result may sound a bit strange, but it would consolidate all my floating layout windows to one floating window with tabs.

           

          Before:

          ( three free floating layout windows open )

           

          1-FloatingWindows-NotConsolidated.png

           

          After consolidation to the active window:

           

          2-FloatingWindows-Consolidated.png

           

          But that would not maximize the windows to my screen ( old MacBook Pro ).
          Here another step to maximize the windows:

           

          app.menuActions.item("$ID/kConsolidateAllDocumentsMenuItem").invoke();
          app.layoutWindows[0].maximize();
          

           

          After:

           

          3-FloatingWindows-Consolidated-Maximized.png

           

          And app.layoutWindows[0].bounds [y1,x1,y2,x2] returned something like: 104,32,849,1401
          ( I'm using an old MacBook Pro ).

           

          Setting the bounds will work like this:

           

          app.layoutWindows[0].bounds = [104,237,849,1401];
          

           

          Result:

           

          4-FloatingWindows-Consolidated-Resized.png

           

           

          Regards,
          Uwe

          • 2. Re: Moving and Sizing the activeDocument Window?
            Bill McLean Level 1

            HI Uwe,

             

            Thank so much for the reply. The problem is that I was trying to set the bounds of the ActiveWindow rather than the layoutWindows bounds. This is what I have going so far:

             

            Fullscreen_2016-10-24__12_18_PM.png

             

            I do appreciate the problem with the modal window. On the initial show of the modal dialog, I close the window and then get the size of the dialog. I then position and size the activeWindow accordingly and then reopen the dialog.

             

            I will using the layoutWindows rather than the ActiveWindow as the target for setting the bounds.

            • 3. Re: Moving and Sizing the activeDocument Window?
              Laubender Adobe Community Professional & MVP

              Bill McLean wrote:

               

              HI Uwe,

               

              Thank so much for the reply. The problem is that I was trying to set the bounds of the ActiveWindow rather than the layoutWindows bounds.

               

              I will using the layoutWindows rather than the ActiveWindow as the target for setting the bounds.

              Hi Bill,

              that's rather strange.
              The active window should have worked as well.


              At least I thought so…
              Tested with activeWindow.bounds instead of layoutWindows[0].bounds and the window was resized as I wished.

               

              Have to test that with my CC version of InDesign.
              My screens are from CS6 v8.1.0 on OSX 10.6.8.

               

              What is your exact version of InDesign?

              On what OSX?

               

              Regards,
              Uwe

              • 4. Re: Moving and Sizing the activeDocument Window?
                Bill McLean Level 1

                Hi Uwe,

                 

                I'm running the latest version of InDesign Creative Cloud on Mac OS (10.12.2).

                 

                I'm having the same behaviour as before.  I'm working on creating a minimum sized code example that exhibits the bad behaviour.  It's good to know that I was not doing something stupid .

                 

                I'll post it once It down to the bare essentials.


                Cheers

                 

                 

                Bill

                • 5. Re: Moving and Sizing the activeDocument Window?
                  Bill McLean Level 1

                  Hi Uwe,

                   

                  Here is my test code the illustrates the problem:

                   

                  // Save the current InDesign settings.

                   

                  function uiSettings()

                  {

                    this.useApplicationFrame = app.generalPreferences.useApplicationFrame;

                    this.applicationBarShown = app.generalPreferences.applicationBarShown;

                    this.showRulers = app.viewPreferences.showRulers;

                    this.activeWindowBounds = app.activeWindow.bounds;

                    this.zoomPercentage = app.activeWindow.zoomPercentage;

                    this.allowGraphicsToResize = app.layoutAdjustmentPreferences.allowGraphicsToResize;

                    this.allowRulerGuidesToMove = app.layoutAdjustmentPreferences.allowRulerGuidesToMove;

                    this.enableLayoutAdjustment = app.layoutAdjustmentPreferences.enableLayoutAdjustment;

                    this.allowGraphicsToResize = app.layoutAdjustmentPreferences.allowGraphicsToResize;

                    this.allowRulerGuidesToMove = app.layoutAdjustmentPreferences.allowRulerGuidesToMove;

                   

                   

                   

                    app.layoutAdjustmentPreferences.enableLayoutAdjustment = true;

                    app.layoutAdjustmentPreferences.allowGraphicsToResize = true;

                    app.layoutAdjustmentPreferences.allowRulerGuidesToMove = true;

                   

                   

                    app.generalPreferences.useApplicationFrame = false;

                    app.generalPreferences.applicationBarShown = false;

                    app.viewPreferences.showRulers = false;

                    app.activeWindow.zoomPercentage = 100;

                    var myMenuAction = app.menuActions.item("$ID/Control");

                    myMenuAction.invoke();

                    var myMenuAction = app.menuActions.item("$ID/Float All in Windows");

                    myMenuAction.invoke();

                    myMenuAction = app.menuActions.item("$ID/Consolidate All Windows");

                    myMenuAction.invoke();

                   

                   

                    app.layoutWindows[0].maximize();

                    app.layoutWindows[0].bounds[1] = 237;

                  }

                   

                   

                  uiSettings.prototype.restore = function()

                  {

                    var myMenuAction = app.menuActions.item("$ID/Control");

                    myMenuAction.invoke();

                    app.layoutAdjustmentPreferences.enableLayoutAdjustment = this.enableLayoutAdjustment

                    app.layoutAdjustmentPreferences.allowGraphicsToResize = this.allowGraphicsToResize;

                    app.layoutAdjustmentPreferences.allowRulerGuidesToMove = this.allowRulerGuidesToMove;

                   

                   

                    app.generalPreferences.applicationBarShown = this.applicationBarShown;

                    app.generalPreferences.useApplicationFrame = this.useApplicationFrame;

                    app.viewPreferences.showRulers = this.showRulers;

                    app.activeWindow.zoomPercentage = this.zoomPercentage;

                  }

                   

                   

                   

                  ui = new uiSettings();

                   

                   

                  ui.restore();

                   

                  with above code set a breakpoint at the ui.restore.

                   

                  Cheers !

                  • 6. Re: Moving and Sizing the activeDocument Window?
                    Laubender Adobe Community Professional & MVP

                    Hi Bill,

                    I suggest not to do something like that:

                     

                    app.layoutWindows[0].bounds[1] = 237;
                    

                     

                    instead:

                     

                    //Store the actual bounds:
                    var boundsLayoutWindow = app.layoutWindows[0].bounds;
                    var offsetX = 237;
                    
                    //and apply them like that:
                    app.layoutWindows[0].bounds =
                    [
                        boundsLayoutWindow[0] ,
                        offsetX ,
                        boundsLayoutWindow[2] ,
                        boundsLayoutWindow[3]
                    ];
                    

                     

                    Regards,
                    Uwe

                    • 7. Re: Moving and Sizing the activeDocument Window?
                      Bill McLean Level 1

                      Uwe,

                       

                      I have changed my code as suggested above. The layout window is not being sized.  I will have to find an earlier version of InDesign to test on.

                       

                       

                      Cheers

                      • 8. Re: Moving and Sizing the activeDocument Window?
                        Laubender Adobe Community Professional & MVP

                        In the meanwhile I tested with my CC 2015.4 v11.4.1.102 on OSX 10.10.5.
                        Had some strange results.

                         

                        Still have to figure out what's going on…
                        As it seems something is working. But only every second try.

                         

                        Cheers,
                        Uwe