Skip to main content
Participant
December 23, 2017
Answered

Fit to screen js script

  • December 23, 2017
  • 2 replies
  • 4461 views

Hello,

Is there a script line for "Fit to screen" in ps?

This topic has been closed for replies.
Correct answer Geppetto Luis

TRY

runMenuItem(app.charIDToTypeID("FtOn")); // FIT TO SCREEN

runMenuItem(app.charIDToTypeID("ZmOt")); // ZOOM -

runMenuItem(app.charIDToTypeID("ZmIn")); // ZOOM +

runMenuItem(app.charIDToTypeID("ActP")); // ACTUAL PIXEL

2 replies

Kukurykus
Legend
December 23, 2017

You may use one of my old functions. It's named 'fit', but it does different stuff for real. It depends on inserted value:

function fit(ft) {// SCREEN FITTING:

     function cTT(v) {return charIDToTypeID(v)}; function sTT(v) {return stringIDToTypeID(v)}

     tle = RegExp(tV = 'tileVertically').test(ft) ? (/^\d\.|10/.test(version) ? tV : ((function(){if (documents.length == 2) fit('consolidateAllTabs')})(), 'Tile')) : ft;

     (ref = new ActionReference()).putEnumerated(cTT('Mn  '), cTT('MnIt'), eval((tle.length <= 4 ? 'c' : 's') + 'TT(tle)'));

     (dsc = new ActionDescriptor()).putReference(cTT('null'), ref), executeAction(cTT('slct'), dsc, DialogModes.NO)

}

fit('FtOn')

Geppetto Luis
Legend
December 24, 2017

Kukurykus

excuse what is the difference

they are both the same thing.

Kukurykus
Legend
December 24, 2017

When you put that code to your library (in other file for example) you can use it in your current code as  fit('<value>'). Many ScriptListener codes when you use often you can shorten to similar form. So you dont have each time use long lines of code but only short function calling. Its useful when you use it many times in one / more code(s), especially with different values.

In CS2 and CS3 both 'Tile' and 'tileVertically' worked, but in CS4 and CS5 'tileVertically' was removed while 'Tile' behaviour was changed to 'tileVerticaly'. Now you could use 'tileVertically' as old 'Tile', but couldn't anymore use 'Tile' old way. To fix it I found a trick. If I wanted two images were distributed horizonatally I had to use that code which after 'consolidateAllTabs' making, palyed 'Tile' so forced images to be distributed vertically. In CS6 there still wasn't 'tileVertically' but 'Tile' behaviour was changed back to original 'Tile'. So not matter you used 'tileVertically' or 'Tile' with my function with 'consolidateAllTabs' or not, as each time images were distributed vertically. You had no chance to make horizontal distribution by a script. They actually add new distribution options (for even more than two images), that you could chose between other things vertical distribution but unfortunatelly that wasnt scriptable so completetly useless for me, as I dont lose time to do things manually during job if something can be automated. Even with shortcuts it would bew additional manual operation I had to perform many times a day, so really wasteful.

Well I often worked on vertical orientation monitor (so height was longer than width), it's why I I needed my function to use, however as I say that was not possible to do with CS6 as far you didn't choose it manyally. That really strange some people in Adobe do things for worse :/ First they destroeyd perfect 'tileVertically' and 'Tile' options, to make 2nd working as first (?!), then when I finally found a remedy for this problem (with 'consolidateAllTabs') they restored old 'Tile' but prevend horizontal distribution by scritping. I'm asking why to change something what is perfect, and then changing that once again that you even can't make workaround ?! The more replacing it with something what is commonly unuseful during working.

Ps. you can use fit() to other items from View menu. What is good you can use values interchangeably as strings and chars.

Geppetto Luis
Geppetto LuisCorrect answer
Legend
December 23, 2017

TRY

runMenuItem(app.charIDToTypeID("FtOn")); // FIT TO SCREEN

runMenuItem(app.charIDToTypeID("ZmOt")); // ZOOM -

runMenuItem(app.charIDToTypeID("ZmIn")); // ZOOM +

runMenuItem(app.charIDToTypeID("ActP")); // ACTUAL PIXEL

Participant
December 23, 2017

Thank You