10 Replies Latest reply on Sep 15, 2018 2:41 AM by Kukurykus

    Fit to screen js script




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

        • 1. Re: Fit to screen js script
          geppettol66959005 Level 3


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

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

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

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

          • 3. Re: Fit to screen js script
            Kukurykus Adobe Community Professional

            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)
            • 4. Re: Fit to screen js script
              geppettol66959005 Level 3


              excuse what is the difference

              they are both the same thing.

              • 5. Re: Fit to screen js script
                Kukurykus Adobe Community Professional

                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.

                • 6. Re: Fit to screen js script
                  geppettol66959005 Level 3

                  Excellent explanation

                  thank you

                  • 7. Re: Fit to screen js script
                    Kukurykus Adobe Community Professional

                    Btw here'e something really funny when you read all posts to the end (focus on years):

                    Bridge: ExtendScript UI not drawing correctly | Photoshop Family Customer Community

                    1 person found this helpful
                    • 8. Re: Fit to screen js script
                      olverart Level 1

                      How do you know those Action Manager codes? I tried to run Script Listener but it doesn´t record that way haha! Where do you found that info or where did you learn it? Thank you in advance!

                      • 9. Re: Fit to screen js script
                        r-bin Level 5

                        To get the code to call the menu or create a path, use the items in the drop-down menu of the Actions palette "Insert Menu Item ..." and "Insert Path".

                        • 10. Re: Fit to screen js script
                          Kukurykus Adobe Community Professional

                          Loll I missed 'Insert Path'. To be honest I don't know how that happened but I never saw that item :/