Photoshop script for Expand/Contract of Selection

Hi!
I need script that will make Expand or Contract Selection for example 1px each time I hit keyboard shortcut. I mean I would like to use this options because I use it very often but I would like without dialog box when PS ask for value of expand/contract. When I will have script for those I could make it by wheel in my Intuos Pro. Now I can't because every time I have dialog box. Thanks in advance for help!
Regards
Arek

cool, thanks, the script works great!
#target photoshop
app.bringToFront();
try {
        // test for active selection
        if (hasSelection(app.activeDocument)) {
            // expand selection
            //app.activeDocument.selection.expand(new UnitValue (100, "px"))   
            // contract selection
            app.activeDocument.selection.contract(new UnitValue (100, "px"))
        else {
            alert ("ERROR: no active selection \n USAGE: the script requires an active selection")
catch (e) {
        alert ("ERROR: the script did not execute")
//////////// FUNCTIONS ////////////
function hasSelection(doc) {
  var res = false;
  var as = doc.activeHistoryState;
  doc.selection.deselect();
  if (as != doc.activeHistoryState) {
    res = true;
    doc.activeHistoryState = as;
    return res;

Similar Messages

  • How to make a script for expand column width

    Hi experts,
    Is that possible to make a script for expand the column width aim to let the columns show up all the overset text?
    Regard
    John

    Hi John,
    As Uwe advised it would be wise to put a stop on any while loop in case the condition is never fulfilled which would mean the script will break.
    Without knowing what specifically you are working on you could make the below amendments to do this.
    myTables = app.documents[0].stories.everyItem().tables.everyItem().getElements();
    for (var t = 0; t < myTables.length; t++) {
        BE_resizeColumnsToFitContents(myTables[t], 200);
    function BE_resizeColumnsToFitContents(tableToEdit, tableMaxWidth) {
        for (var i = 0; i < tableToEdit.columns.length; i++) {
            while (tableToEdit.columns[i].overflows === true) {
                if (tableToEdit.width < tableMaxWidth) {
                    tableToEdit.columns[i].width += 1;
                    tableToEdit.columns[i].recompose();
                else {
                    alert("Column " + i + " contents too large for column.");
                    break;
    I won't put any extra functions in this because it might not be what you're after. To use this you just define the table width as a second argument to the function (but you could change this parameter to something else, like page, column or cell width). And, if you want to have a fail action you just put it in the 'else' part.
    Brett

  • Photoshop script Get template from Bridge selection

    Hi,
    I was looking for a script to get selected template pdf file in bridge selection to open in photoshop by an photoshop plugin. script should auto configure by default to document size as pervious opened or created document. Later user need to select a bunch of images to set in that opened document of the template.    

    Rags also has a script to build PSD collage templates and scripts to populate then and there is my Photo Collage Toolkits the make it easy to create template files and populate then. Also included is a script the lets you tile images into a document.  Designed to let you ptint image on roll paper without paper waste.
    Photo Collage Toolkit UPDATED Dec 3, 2012 Added Animated SnowGlobe, SnowGlobe Action Set, SnowGlobe Template and SnowGlobe Video Demo.
    http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html
    Paste Image Roll http://www.mouseprints.net/old/dpr/PasteImageRoll.html

  • Wanted: Bridge or Photoshop script for taking a camera raw "snapshot"

    Hello,
    i am looking for a way to create a "snapshot" in the xmp data of raw image files, like you do in camera raw's last tab "snapshots".
    I can do copy&paste programming.
    Here is a script that changes a certain value on a selection of image files. I  can take this as a starting point to work  in the xmp data in a selection of files. But what would a function to create a snapshot be?
    #target bridge    if( BridgeTalk.appName == "bridge" ) {
    setExposure = MenuElement.create("command", "Set Average Exposures", "at the end of Tools","exp");
    setExposure.onSelect = function () {
    var d=app.document;
    d.deselectAll();
    var sels = d.getSelection("cr2,crw,nef,mos,orf");
    var noOfFiles =sels.length;
    var diff = (3.25 / (noOfFiles-1));
    var exp = 1.25;
    var exp2=exp;
    for(var a = 0;a<noOfFiles;a++){
        exp2 = exp - (diff*(a)).toFixed(3);
        var file = new File(sels[a].spec.toString().replace(/\....$/,'.xmp'));
        setExposure( file, exp2 )
    app.document.chooseMenuItem('PurgeCache');
    function setExposure( file, expose ){
         file.open('r');
         file.encoding = "UTF8";
         file.lineFeed = "unix";
         file.open("r", "TEXT", "????");
         var xmpStr = file.read();
         file.close();
         if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
         var xmp = new XMPMeta( xmpStr );
         xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Exposure", Number(expose) );
         file.open('w');
         file.encoding = "UTF8";
         file.lineFeed = "unix";
         file.write( xmp.serialize() );
         file.close();
    regards,
    Stephan Möbius

    Hi Stephan,
    Nice to hear from you.
    I would first like to tell my understanding your problem clearly.
    What I understood is that you want create a “snapshot” (thumbnail) of a camera raw file and put it inside the XMP Packet.
    You have got a script which can update XMP of file, on selecting a menu item.
    You want to know how to create a “snapshot” of a raw file so that you can insert it in XMP using the script.
    Workflow will be, you will open a camera raw file, select some menu item, and on doing that the snapshot will be updated in the XMP.
    Is this understanding correct?
    If not please clarify the workflow and the problem you are facing.
    Thanks,
    Amit

  • CATT script for creating Contract Detail lines

    In my requirement I have to use the transaction SCAT and record the transaction ME31K for creating the line items. But when adding more than 1 line item the function is not working only the first detailed line item is added, no more. Please help.

    Hi shashikant
    Use  Message type BLAORD .. FM: IDOC_OUTPUT_BLAORD (Process code is ME15 (Not sure)  in AFS it is /afs/md15- BLAORD:  AFS Contract via EDI)
    Thanks
    Ramesh
    302 290 5677

  • What is a keyboard shortcut for expanding/contracting current window?

    What is the keyboard shortcut for maximizing/minimizing the current window?

    Alt-Space to open the system menu doesn't seem to work anymore with Firefox 6 on Windows 7.

  • Script for copying contracts

    Looking a script to copy contacts from outlook 2010 to office 365. Thanks
    This topic first appeared in the Spiceworks Community

    Looking a script to copy contacts from outlook 2010 to office 365. Thanks
    This topic first appeared in the Spiceworks Community

  • Script for creating grid spreads of photos from the Adobe Bridge

    Hi,
    Someone once showed me a script for being able to select multiple images while looking at them in the bridge and making grid layouts on pages from them. Does anyone know how to do that? Thanks!

    The only code that I have seen that does this sort of thing is to be found here. http://forums.adobe.com/message/5713633

  • Interactive selection using photoshop script

    How to make a script pause till the user makes a selection and continue again using photoshop script?

    You can use two Scripts or one Script that, depending on some predetermined factor, performs two different tasks.
    So you could for example write something into the metadata, a channel, a txt file, … when a Script is run and that information is absent, and if it isn’t have the Script perform something else and remove that again.
    Edit: You probably could also set up the Script Events Manager to check for something on any Selection change and have it run a Script depending on that but I doubt that’s a good idea.

  • Possible to run a photoshop script by selecting files in Bridge?

    Hi,
    I have a good script I've written that I always used to run from Photoshop. The script has a dialog box which asks where to get the files from. Is it possible to select files in bridge and run the script from there? Without rewriting it for Bridge?
    Thanks,
    Stan

    > I have a good script I've written that I always used to run from Photoshop. The script has a dialog box which asks where to get the files from. Is it possible to select files in bridge and run the script from there? Without rewriting it for Bridge?
    Yes, this is possible. However, a much easier solution is to select the files in
    Bridge then switch to PS manually to run your script. It avoids having to having
    to write any code to run in Bridge at the cost of not having seamless integration.
    In xtools/xlib/XBridgeTalk.jsx I have a set of functions that simplify working
    with Bridge from within PS. For instance:
    var files = XBridgeTalk.getBridgeSelection();
    will return an array of Files that are currently selected in Bridge. If Bridge
    isn't running or if no files are selected it returns an empty array.
    -X
    for photoshop scripting solutions of all sorts
    contact: [email protected]

  • Script for Always Calling the Direct Selection Tool?

    Ok, so first forgive me if this isn't necessarily a scripting question, but I'm hoping it is...
    Would it be possible to write a script that, while using the pen tool, would force Illustrator to always switch to the Direct Selection (white) arrow when holding down Ctrl (Cmd)? In my workflow, I never have use for accessing the regular Selection Tool while I'm using the pen tool (or very rarely). In essence, I would just love if Illy's pen tool behaved the same as InDesign's and Photoshop's! Anyone know if something like this is scriptable?
    Thanks in advance!
    Andy

    Google "illustrator pen tool direct selection" , for example the following...
    http://vector.tutsplus.com/tutorials/tools-tips/illustrators-pen-tool-the-comprehensive-gu ide/
    Select the Direct Selection tool before selecting the Pen tool. Press and hold Command (Ctrl)
    to give you access to the last tool selected (in this case the Direct Selection tool) for editing
    of paths and handles without deselecting the path.
    Is that what you mean?

  • Reworking Photoshop layer renaming script for Illustrator

    The Photoshop scripting guru Paul R over at RetouchPro has created a really cool script to batch rename and number selected Photoshop layers. I haven't found anything similar on the Illustrator side.
    He's given permission for me to post it here in my hopes that some Illustrator scripting genius could come up with a similar script for Illustrator. Would it be terribly difficult to convert this into something Illustrator could use?
    http://www.mediafire.com/file/g7usr73u0236p0a/Rename_&_Renumber_Selected_Layers.jsx
    http://www.mediafire.com/file/dbah74x13bsa74c/Rename_&_Renumber_Selected_Layers.jsx.zip

    Hola Julio, I updated the script to rename visible Layers or Sublayers, and also fixed the Color
    #target illustrator
    main();
    function main(){
        if(!documents.length) return;
        //var allLayers = app.activeDocument.layers;
        var win = new Window( 'dialog', '' );
        g = win.graphics;
        //  var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]); // CS5
        var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.50, 0.50, 0.50, 1]); // CS6
        g.backgroundColor = myBrush;
        win.orientation='stack';
        win.p1= win.add("panel", undefined, undefined, {borderStyle:"black"});
        win.g1 = win.p1.add('group');
        win.g1.orientation = "row";
        win.title = win.g1.add('statictext',undefined,'Rename Visible Layers or Sublayers');
        win.title.alignment="fill";
        var g = win.title.graphics;
        g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);
        win.g5 =win.p1.add('group');
        win.g5.orientation = "column";
        win.g5.alignChildren='left';
        win.g5.spacing=10;
        win.g5.st1 = win.g5.add('statictext',undefined,'New layer name');
        win.g5.et1 = win.g5.add('edittext');
        win.g5.et1.preferredSize=[250,20];
        win.g10 =win.p1.add('group');
        win.g10.orientation = "row";
        win.g10.alignment='fill';
        win.g10.spacing=10;
        win.g10.st1 = win.g10.add('statictext',undefined,'Serial Number');
        win.g10.et1 = win.g10.add('edittext',undefined,'1');
        win.g10.et1.preferredSize=[50,20];
        win.g10.et1.onChanging = function() {
          if (this.text.match(/[^\-\.\d]/)) {
            this.text = this.text.replace(/[^\-\.\d]/g, '');
        win.g10.st1 = win.g10.add('statictext',undefined,'Length');
        var nums=[2,3,4,5];
        win.g10.dl1 = win.g10.add('dropdownlist',undefined,nums);
        win.g10.dl1.selection=0;
        win.g15 =win.p1.add('group');
        win.g15.orientation = "row";
        win.g15.alignment='fill';
        win.g15.cb1 = win.g15.add('checkbox',undefined,'Reverse layer order');
        win.g15.cb2 = win.g15.add('checkbox',undefined,'Rename Sublayers Only');
        win.g100 =win.p1.add('group');
        win.g100.orientation = "row";
        win.g100.alignment='center';
        win.g100.spacing=10;
        win.g100.bu1 = win.g100.add('button',undefined,'Rename');
        win.g100.bu1.preferredSize=[120,30];
        win.g100.bu2 = win.g100.add('button',undefined,'Cancel');
        win.g100.bu2.preferredSize=[120,30];
        win.g100.bu1.onClick=function(){
            if(win.g5.et1.text == ''){
                alert("No layer name has been entered!");
                return;
            win.close(0);
            var sublayersOnly = win.g15.cb2.value;
            var visibleLayers = [];
            getVisibleLayers (app.activeDocument, visibleLayers, sublayersOnly);
            if(win.g15.cb1.value) visibleLayers.reverse();
            for(b=0; b<visibleLayers.length; b++){
                var LayerName = win.g5.et1.text + zeroPad((Number(win.g10.et1.text)+Number(b)), Number(win.g10.dl1.selection.text));
                visibleLayers[b].name = LayerName;
        win.center();
        win.show();
        function getVisibleLayers(container, visibleLayers, sublayersOnly) {
            for(var a=0; a<container.layers.length; a++){
                var ilayer = container.layers[a];
                if (ilayer.visible) {
                    if (sublayersOnly) {
                        getVisibleLayers (ilayer, visibleLayers, false); // false to process only 1 sublayer depth
                    else
                    visibleLayers.push(ilayer);
    function zeroPad(n, s) {
        n = n.toString();
        while (n.length < s) n = '0' + n;
        return n;

  • How to make a selection of a layer delete content and paste another content with Photoshop scripting..?

    how to make a selection of a layer delete content and paste another content with Photoshop scripting..?

    There is a more specific Forum …
    Photoshop Scripting

  • What is the procedure/code in VBA for passing the calc scripts dynamically based on the selection.

    Hello Gurus,
    I want to know what is the procedure/code in VBA for passing the calc scripts dynamically based on the selection.
    For example:
    X=EssVCalculate("Sheetname","Calc_Script name",True)
    In the above code instead of the *"Calc_Script name"* I want a script which is called dynamically and the values are calculated accordingly.
    Thanks in advance
    Saurabh

    Hi Todd,
    This is the situation:
    I have a calc script in Essbase which I can call to perform the calculations on the current sheet that is retrieved. I want calculation for the following formulas:
    x = EssVCalculate("Sheet2", "CalcBC", False)
    CalcBC is my calc script which is present in Essbase
    So instead of passing the above script I want to pass the conditions dynamically in the VBA code . I don't want to mention the script name directly in EssVCalculate option
    For example:
    I have three drop down menus from which I would select three different( zero level )members. It would then retrieve the data for that particular values in the excel sheet and now when I click on Calculate button it should calculate the script dynamically.
    I don't know how calc scripts can be executed dynamically in the VBA code itself.
    Thanks in Advance
    Saurabh

  • I have Photoshop CS5. I downloaded the script for contact sheets. It didn't work. How do I do it?

    I have Photoshop CS5. I downloaded the script for contact sheets. It doesn't work. How do I do it?

    Adobe - Photoshop : For Windows : Photoshop CS5 Optional Plugins
    Adobe - Photoshop : For Macintosh : Photoshop CS5 Optional Plug-Ins (Mac)
    Optional Automate Plug-ins:
    NOTE: We strongly encourage the use of the CS5 Optional Automate Plug-Ins Installer over attempting to manually install any of the following Optional Automate Plug-ins:
    • Contact Sheet II
    • Picture Package (ContactSheetII)
    • Web Photo Gallery (WebContactSheetII) plus presets
    • Script for Layer Comps to Web Photo Gallery
    INSTALLATION INSTRUCTIONS
    Refer to the included ReadMe file that has plug-in descriptions and installation instructions.
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Note these also work in the perpetual CS6 Windows version not the Subscription CS6 version.  Some may work on the Mac however Picture Package(Contact sheet II) will not work on the MAC for Mac CS6 is 64Bit only and there was only a 32Bit plug-in for Mac CS6.  There are 32bit and 64bit versions for windows. I install these manually....

Maybe you are looking for

  • Having problems connecting MacBook Pro 2010 TO vizio 60 " tv

    having problems connecting MacBook Pro 2010 TO vizio 60 " tv using mini displayport to VGA adapter non support warning appears pn tv monitor

  • Installing ram into my macbook pro

    so i was wondering if i have the ability to upgrad my current ram from 4GB to 16GB (2x gb ram cards) i know certain models of the mac book pro simply wont function when upgraded, or atleast thats what ive seen personally. I know i could install it my

  • Help with CR Viewer XI

    Post Author: Lee XI CA Forum: General Hello all. I'm currently using CR XI (not server) and downloaded the Viewer yesterday to test on a spare pc. Reason for this is I want others to be able to view and set parameters I designed in the report(s). How

  • How to burn a pre made slideshow

    how to save & then burn a premade slideshow

  • Noisy fans on iMac 24. Help

    Noisy fans in iMac 24 Posted: Aug 2, 2008 1:47 AM Reply Email Hi Guys I need your help on this. My 3 months old iMac (iMac 24inch 2.8GHZ Core 2 Duo Extreme) fans started making so much noise that is unbearable. They came on suddenly (you could see th