6 Replies Latest reply on Oct 14, 2009 2:18 PM by Michael L Hale

    Paste from clipboard?

    Level 1
      I used the listener to get the javascript to copy in an object from InDesign using BridgeTalk. the problem is, I want to use the dimensions from the clipboard every time, not the dimensions recorded during the original "listen", anybody know how to change this?

      Thanks in advance!

      Heres the current script:

      var obj = app.activeDocument.selection;
      //function pasteToPS() {
      var bt = new BridgeTalk;
      bt.target = "photoshop";

      var myScript = '//start\n';
      // insert stuff from PS listener below this line
      // =======================================================
      myScript += 'var id53 = charIDToTypeID( "Mk " );\n';
      myScript += ' var desc8 = new ActionDescriptor();\n';
      myScript += 'var id54 = charIDToTypeID( "Nw " );\n';
      myScript += 'var desc9 = new ActionDescriptor();\n';
      myScript += 'var id55 = charIDToTypeID( "Md " );\n';
      myScript += 'var id56 = charIDToTypeID( "RGBM" );\n';
      myScript += 'desc9.putClass( id55, id56 );\n';
      myScript += 'var id57 = charIDToTypeID( "Wdth" );\n';
      myScript += 'var id58 = charIDToTypeID( "#Rlt" );\n';

      //var from clipboard instead of the 122 value?
      myScript += 'desc9.putUnitDouble( id57, id58, 122.000000 );\n';
      myScript += 'var id59 = charIDToTypeID( "Hght" );\n';
      myScript += 'var id60 = charIDToTypeID( "#Rlt" );\n';

      //var from clipboard instead ofthe 119 value?
      myScript += 'desc9.putUnitDouble( id59, id60, 122.000000 );\n';
      myScript += 'var id61 = charIDToTypeID( "Rslt" );\n';
      myScript += 'var id62 = charIDToTypeID( "#Rsl" );\n';
      myScript += 'desc9.putUnitDouble( id61, id62, 72.000000 );\n';
      myScript += 'var id63 = stringIDToTypeID( "pixelScaleFactor" );\n';
      myScript += 'desc9.putDouble( id63, 1.000000 );\n';
      myScript += 'var id64 = charIDToTypeID( "Fl " );\n';
      myScript += 'var id65 = charIDToTypeID( "Fl " );\n';
      myScript += 'var id66 = charIDToTypeID( "Trns" );\n';
      myScript += 'desc9.putEnumerated( id64, id65, id66 );\n';
      myScript += 'var id67 = charIDToTypeID( "Dpth" );\n';
      myScript += 'desc9.putInteger( id67, 8 );\n';
      myScript += 'var id68 = stringIDToTypeID( "profile" );\n';
      myScript += 'desc9.putString( id68, "sRGB IEC61966-2.1" );\n';
      myScript += 'var id69 = charIDToTypeID( "Dcmn" );\n';
      myScript += 'desc8.putObject( id54, id69, desc9 );\n';
      myScript += 'executeAction( id53, desc8, DialogModes.NO );\n';

      // =======================================================
      myScript += 'var id70 = charIDToTypeID( "past" );\n';
      myScript += 'var desc10 = new ActionDescriptor();\n';
      myScript += 'var id71 = charIDToTypeID( "AntA" );\n';
      myScript += 'desc10.putBoolean( id71, true );\n';
      myScript += 'var id72 = charIDToTypeID( "As " );\n';
      myScript += 'var id73 = stringIDToTypeID( "smartObject" );\n';
      myScript += 'desc10.putClass( id72, id73 );\n';
      myScript += 'var id74 = charIDToTypeID( "FTcs" );\n';
      myScript += 'var id75 = charIDToTypeID( "QCSt" );\n';
      myScript += 'var id76 = charIDToTypeID( "Qcsa" );\n';
      myScript += 'desc10.putEnumerated( id74, id75, id76 );\n';
      myScript += 'var id77 = charIDToTypeID( "Ofst" );\n';
      myScript += 'var desc11 = new ActionDescriptor();\n';
      myScript += 'var id78 = charIDToTypeID( "Hrzn" );\n';
      myScript += 'var id79 = charIDToTypeID( "#Rlt" );\n';
      myScript += 'desc11.putUnitDouble( id78, id79, 0.000000 );\n';
      myScript += 'var id80 = charIDToTypeID( "Vrtc" );\n';
      myScript += 'var id81 = charIDToTypeID( "#Rlt" );\n';
      myScript += 'desc11.putUnitDouble( id80, id81, 0.000000 );\n';
      myScript += 'var id82 = charIDToTypeID( "Ofst" );\n';
      myScript += 'desc10.putObject( id77, id82, desc11 );\n';
        • 1. Re: Paste from clipboard?
          Danny Noonan Level 1

          I am looking this same thing, I want to copy a selected image and paste it into photoshop, then, if possible save the image and place back into ID. Does anyone have any tips or even a script available to do this? I'm currently using InDesign CS4 and PhotoShop CS4. I know it's a long shot, but I just thought I'd through this question out there, this is exactly what need.

          • 2. Re: Paste from clipboard?
            c.pfaffenbichler Level 8

            Would this be intended as a way to correct the unfortunate instances when designers paste images into Indesign instead of linking them?

            • 3. Re: Paste from clipboard?
              Danny Noonan Level 1

              Hello Christoph,

              Fortunately, no. I have seen them do some very stupid things before, but this is what we have found to be the fastest way to create composites and create new scaled images for printers dpi regulations. I have seen many scripts that will scale and rotate the original placed link. Those scripts may work fine but they don't crop the images to the bleed size as copying from ID and pasting into PS would. This is important because sometimes we are dealing with 1 gig files, then scaling them up creates what is basically an unusable file. Is this something that could logically be scripted? Have you seen one like this?


              What we manually do now, which is what I would like to script is:     Select image(s) in ID, copy, in Photoshop make a new document, 300 dpi, CMYK, no color management. Then we would paste the clipboard data into this new Photoshop document as a smart object, with the top left corner 0 px, 0 px. Then we save it out using the original links name with an _xxx (xxx is the percent the link was placed in ID) added to the end of the name. We save them as flat tifs with LZW compression to a designated "Scaled Links" folder. Then, we place it in ID at 100%, at bleed.

              As you can see, this is a relatively simple task, but can be time consuming if you need to do it 50 times my 3:30 this afternoon! If you have any tips or suggestions, I would greatly appreciate it.





              • 4. Re: Paste from clipboard?
                Michael L Hale Level 5

                This only works with CS4 but you can use the 'clipboard' preset to make the new document. The new doc will have the size and color space of the clipboard contents.


                var desc = new ActionDescriptor();
                    var desc1 = new ActionDescriptor();
                    desc1.putString( stringIDToTypeID( "preset" ), "Clipboard" );
                desc.putObject( charIDToTypeID( "Nw  " ), charIDToTypeID( "Dcmn" ), desc1 );
                executeAction( charIDToTypeID( "Mk  " ), desc, DialogModes.NO );


                That way the new doc will always be the size of the obj copied in InDesign.

                • 5. Re: Paste from clipboard?
                  Danny Noonan Level 1

                  Thanks Michael,


                  I just tried it and it works perfect! Thanks for your response. I'm pretty new to Javascripting and this is my first attempt doing any in Photoshop so any help is much appreciated. As far as the object model viewer for Photoshop, has anyone created any alternatives? I know there are some pretty nice ones out there for InDesign. Also, what is BridgeTalk. I've seen brought up a few times in the Photoshop forums. Is it needed when scripting for multiple applications?


                  Thanks again Michael.



                  • 6. Re: Paste from clipboard?
                    Michael L Hale Level 5

                    I know that there is an object model viewer for Photoshop in ESKT but I don't use in. I just refer to the javascripting guide. But I don't think any object viewer would have helped in this case as it only shows DOM objects and document presets are not part of the DOM.


                    As I understand it you need BridgeTalk to script multiple applications in javacript becuse js runs in the host app. BridgeTalk allows you to sent script to another Adobe app. If you were scirpt using VBS or Applescript it's not needed as those run in the OS.