Hi Ps-Design. I tested the action here and actually saw that the dialog does not open! I tried with that first version and it worked however the slider navigation is kinda heavy. Maybe this will help! #target photoshop; app.bringToFront(); main(); function main(){ var strokeSize = getStrokeSize(); if(strokeSize == null) return; var d= new Window('dialog','Style'); d.grpOpacity = d.add('panel', undefined,'Stroke'); d.grpOpacity.orientation = 'row'; d.grpOpacity.alignChildren = ['fill','top']; d.grpOpacity.grpSlider = d.grpOpacity.add('group'); d.grpOpacity.grpSlider.spacing = 0; d.grpOpacity.grpSlider.orientation = 'row'; d.grpOpacity.grpSlider.st1 = d.grpOpacity.grpSlider.add('statictext',undefined,'Stroke-Size'); d.grpOpacity.grpSlider.st1.alignment = 'left'; d.grpOpacity.grpSlider.grpSlider = d.grpOpacity.grpSlider.add('group'); d.grpOpacity.grpSlider.grpSlider.alignChildren = ['left','center']; d.grpOpacity.grpSlider.grpSlider.spacing = 0; d.slOpacity = d.grpOpacity.grpSlider.grpSlider.add('slider',undefined,0,0,255); d.slOpacity.value = strokeSize; d.slOpacity.preferredSize.width =100; d.etOpacityValue = d.grpOpacity.grpSlider.grpSlider.add('edittext'); d.etOpacityValue.text = strokeSize; d.etOpacityValue.addEventListener ('keydown', InitEditKeyboardHandler ); d.etOpacityValue.preferredSize.width = 40; d.grpOpacity.grpSlider.grpSlider.stUnit = d.grpOpacity.grpSlider.grpSlider.add('statictext',undefined,' Pixels'); d.grpOpacity.grpSlider.grpSt = d.grpOpacity.grpSlider.add('group'); d.grpOpacity.grpSlider.grpSt.orientation = 'row'; d.grpOpacity.grpSlider.grpSt.alignment = 'fill'; d.grpOpacity.grpSlider.grpSt.spacing = 0; d.grpOpacity.grpSlider.grpSt.margins = [5,0,0,0]; d.grpOpacity.grpSlider.grpSt.grpLeft = d.grpOpacity.grpSlider.grpSt.add('group'); //d.grpOpacity.grpSlider.grpSt.grpLeft.st1 = d.grpOpacity.grpSlider.grpSt.grpLeft.add('statictext',undefined,'0'); //d.grpOpacity.grpSlider.grpSt.grpLeft.st1.alignment = ['left','center']; //d.grpOpacity.grpSlider.grpSt.grpLeft.st1.preferredSize.width = 200; //d.grpOpacity.grpSlider.grpSt.grpLeft.st3 = d.grpOpacity.grpSlider.grpSt.grpLeft.add('statictext',undefined,'255'); //d.grpOpacity.grpSlider.grpSt.grpLeft.st3.alignment = ['right','center']; //d.grpOpacity.grpSlider.grpSt.grpLeft.st3.preferredSize.width = 50; d.grpButtons = d.add('group'); d.grpButtons.alignment = "right"; d.grpButtons.btnCanel = d.grpButtons.add('button', { x: 240,y: 125, width: 75, height: 25 }, 'Cancel', {name: 'cancel'}); d.grpButtons.btnOK = d.grpButtons.add('button', { x: 90, y: 125, width: 75, height: 25 }, 'Ok', { name: 'ok' }); d.etOpacityValue.onChanging = d.etOpacityValue.onChange = function(){ var d = FindDialog(this); d.slOpacity.value = Number(this.text); d.slOpacity.onChange(); } d.slOpacity.onChanging = d.slOpacity.onChange = function(){ var d = FindDialog(this); d.etOpacityValue.text = Math.round(this.value); } d.slOpacity.onChange = function(){ var d = FindDialog(this); setStrokeSize(Math.round(this.value)); // app.activeDocument.activeLayer.opacity = Math.round(this.value); app.refresh(); } d.grpButtons.btnCanel.onClick=function(){ d.close(2); setStrokeSize(strokeSize); } d.show(); function FindDialog( inItem ) { var w = inItem; while ( 'dialog' != w.type ) { if ( undefined == w.parent ) { w = null; break; } w = w.parent; } return w; }; function KeyHasModifier (event) { return event.shiftKey || event.ctrlKey || event.altKey || event.metaKey; } function KeyIsNumeric (event) { return (event.keyName >= '0') && (event.keyName <= '9') && ! KeyHasModifier (event); } function KeyIsDelete (event) { // Shift-delete is ok return (event.keyName == 'Backspace') && ! (event.ctrlKey); } function KeyIsLRArrow (event) { return ((event.keyName == 'Left') || (event.keyName == 'Right')) && ! (event.altKey || event.metaKey); } function KeyIsTabEnterEscape (event) { return event.keyName == 'Tab' || event.keyName == 'Enter' || event.keyName == 'Escape'; } function InitEditKeyboardHandler (event) { try { var keyIsOK = KeyIsNumeric(event) || KeyIsDelete(event) || KeyIsLRArrow(event) || KeyIsTabEnterEscape(event); if (! keyIsOK) { event.preventDefault(); app.beep(); } } catch (e) { } }; }; // helper function for working with descriptors by Mike Hale function getActiveLayerProperty( psKey, psType ) { var ref = new ActionReference(); ref.putProperty( charIDToTypeID( 'Prpr' ), psKey ); ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); if( undefined == psType ){ return executeActionGet( ref ).getObjectValue( psKey ); }else{ return executeActionGet( ref ); } }; function duplicateDescriptor( descriptor ) { var newDescriptor = new ActionDescriptor; newDescriptor.fromStream( descriptor.toStream() ); return newDescriptor; }; function localizeDescriptor( desc ) { var stream, pointer, zStringLength, zstring, localized_string, newZStringLength, previousStream, followingStream, newDesc; stream = desc.toStream(); while( true ) { pointer = stream.search(/TEXT....\x00\$\x00\$\x00\$/); if( pointer === -1 ) { break; } zStringLength = getLongFromStream( stream, pointer + 4 ); zstring = readUnicode( stream.substr( pointer + 8, ( zStringLength - 1 ) * 2) ); localized_string = ( localize( zstring ) ) + '\u0000'; newZStringLength = localized_string.length; previousStream = stream.slice( 0, pointer); followingStream = stream.slice( pointer + 8 + zStringLength * 2); stream = previousStream.concat( 'TEXT', longToString( newZStringLength ), bytesToUnicode( localized_string ), followingStream ); } newDesc = new ActionDescriptor(); newDesc.fromStream( stream ); return newDesc; }; function getShortFromStream( stream, pointer ) { var hi, low; hi = stream.charCodeAt( pointer ) << 8 ; low = stream.charCodeAt( pointer + 1 ); return hi + low; }; function getLongFromStream( stream, pointer ) { var hi, low; hi = getShortFromStream( stream, pointer) << 16; low = getShortFromStream( stream, pointer + 2); return hi + low; }; function readUnicode( unicode ) { var string = ""; for( i = pointer = 0; pointer < unicode.length; i = pointer += 2) { string +=String.fromCharCode( getShortFromStream( unicode, pointer ) ); } return string; }; function longToString( longInteger ) { var string; string = String.fromCharCode( longInteger >>> 24 ); string += String.fromCharCode( longInteger << 8 >>> 24 ); string += String.fromCharCode( longInteger << 16 >>> 24 ); string += String.fromCharCode( longInteger << 24 >>> 24 ); return string; }; function bytesToUnicode( bytes ) { var unicode = "", char_code, charIndex; for( charIndex = 0; charIndex < bytes.length; charIndex ++ ) { char_code = bytes.charCodeAt( charIndex ); unicode += String.fromCharCode(char_code >> 8 ) + String.fromCharCode( char_code & 0xff ); } return unicode; }; function setStrokeSize(Size ) { var layerEffects, newLayerEffects, currentDesc, newDesc, colorDesc, newLayerEffects, layerDesc, targetDesc, setDesc; layerEffects = getActiveLayerProperty( charIDToTypeID( 'Lefx' ) ); newLayerEffects = duplicateDescriptor( layerEffects ); currentDesc = layerEffects.getObjectValue( stringIDToTypeID( 'frameFX') ); newDesc = duplicateDescriptor( currentDesc ); newDesc.putUnitDouble( charIDToTypeID('Sz '), charIDToTypeID('#Pxl'), Size ); newLayerEffects.putObject( stringIDToTypeID( 'frameFX'), stringIDToTypeID( 'frameFX'), newDesc ); newLayerEffects = localizeDescriptor( newLayerEffects ); layerDesc = new ActionDescriptor(); layerDesc.putObject( charIDToTypeID('Lefx'), charIDToTypeID('lfxv'), newLayerEffects); targetDesc = new ActionReference(); targetDesc.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); setDesc = new ActionDescriptor; setDesc.putObject( charIDToTypeID('T '), charIDToTypeID('Lyr '), layerDesc ); setDesc.putReference( charIDToTypeID('null' ), targetDesc ); executeAction(charIDToTypeID('setd'), setDesc, DialogModes.NO); }; function getStrokeSize(){ var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); var desc = executeActionGet(ref); if(desc.hasKey(stringIDToTypeID( 'layerEffects' ))){ if(!desc.getBoolean (stringIDToTypeID( 'layerFXVisible'))) return undefined; desc = desc.getObjectValue(stringIDToTypeID('layerEffects')); if(!desc.hasKey(stringIDToTypeID( 'frameFX'))) return null; desc = desc.getObjectValue(stringIDToTypeID('frameFX')); return desc.getUnitDoubleValue (stringIDToTypeID( 'size' )); } return null; };
... View more