Skip to main content
Inspiring
August 15, 2016
Answered

control document window size/position?

  • August 15, 2016
  • 2 replies
  • 1340 views

Is there any way to us javascript (or anything else) to control the document window size (33.3%, 66.6%, etc) or position on-screen?

This topic has been closed for replies.
Correct answer c.pfaffenbichler

As for the zoom:

// by michael l hale;

function setZoom( zoom ) {// as percent

   cTID = function(s) { return app.charIDToTypeID(s); }; // from xbytor

   var docRes = activeDocument.resolution;

   activeDocument.resizeImage( undefined, undefined, 72/(zoom/100), ResampleMethod.NONE );

   var desc = new ActionDescriptor();

   var ref = new ActionReference();

   ref.putEnumerated( cTID( "Mn  " ), cTID( "MnIt" ), cTID( 'PrnS' ) );

   desc.putReference( cTID( "null" ), ref );

   executeAction( cTID( "slct" ), desc, DialogModes.NO );

   activeDocument.resizeImage( undefined, undefined, docRes, ResampleMethod.NONE );

};

app.activeDocument.suspendHistory ("zoom", "setZoom( 65 )");

2 replies

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
August 15, 2016

As for the zoom:

// by michael l hale;

function setZoom( zoom ) {// as percent

   cTID = function(s) { return app.charIDToTypeID(s); }; // from xbytor

   var docRes = activeDocument.resolution;

   activeDocument.resizeImage( undefined, undefined, 72/(zoom/100), ResampleMethod.NONE );

   var desc = new ActionDescriptor();

   var ref = new ActionReference();

   ref.putEnumerated( cTID( "Mn  " ), cTID( "MnIt" ), cTID( 'PrnS' ) );

   desc.putReference( cTID( "null" ), ref );

   executeAction( cTID( "slct" ), desc, DialogModes.NO );

   activeDocument.resizeImage( undefined, undefined, docRes, ResampleMethod.NONE );

};

app.activeDocument.suspendHistory ("zoom", "setZoom( 65 )");

Jarda Bereza
Inspiring
August 15, 2016

Nice hack... image resize without resizing image used for zoom :-) :-D

You also can run menu items for

100% size and then increase or decrease zoom and use another similar commands

Jarda Bereza
Inspiring
August 15, 2016

I would try to write AutoHotkey script (windows) and then compile it in .exe file and you could run it from script. Maybe you could run this exe file with arguments, which will contains size and position. Maybe somebody already did program like this.

You can move window which are created by UI Scripting (.jsx) (not document window, but maybe some some default dialogs)

You can change workspaces but it doesn't include document window.

You can run menu items: Window > Arrange

You can read number of displays and their dimensions.