Skip to main content
smithcgl9043167
Inspiring
September 13, 2018
Answered

How to save input values from text box?

  • September 13, 2018
  • 1 reply
  • 3365 views

I searched here and saw a good example using customOptions.

 

 

Why does not my Photoshop recognize this string?

("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8")

 

How to find, get and validate these string so that it works perfectly?

I saw something here but it did not work in any key I generated.

uuidgen

 

Here is a small dialog box with two text boxes that I need to save the values whenever I need to open the window.

dlg = new Window("dialog", "new project", [0, 0, 255, 100], {resizeable: true});
text01 = dlg.add("edittext", {x: 26, y: 26, width: 48, height: 20}, "");
text02 = dlg.add("edittext", {x: 86, y: 26, width: 48, height: 20}, "");
var desc = app.getCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8");
text01.text = desc.getString(0); button = dlg.add("button", [162, 26, 232, 46], "Ok");

button.onClick = function() {
	var desc = new ActionDescriptor(); 
	desc.putString(0, text01.text); 
	app.putCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8", desc, true); 
}

dlg.center();
dlg.show();

Can anyone explain to me how this method works?

This topic has been closed for replies.
Correct answer r-bin

var desc = null;

try { desc = app.getCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8"); } catch (e) {};

if (desc) text01.text = desc.getString(0);

1 reply

r-binCorrect answer
Legend
September 13, 2018

var desc = null;

try { desc = app.getCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8"); } catch (e) {};

if (desc) text01.text = desc.getString(0);

Kukurykus
Legend
March 24, 2020

How to check custom option exists without try...catch statement?

 

Is there some ActionDescriptor key for?

 

Personally I found in 'C:\Users\Marek\AppData\Roaming\Adobe\Adobe Photoshop CS6\Adobe Photoshop CS6 Settings\Adobe Photoshop X64 CS6 Prefs.psp'

 

they are stored at the moment of quitting Photoshop, I mean their name after:

 

5d9bdc30-d980-4d66-92b8-3fdb0eb270c5

 

What is interesting when I did:

 

typeIDToStringID(getCustomOptions('5d9bdc30-d980-4d66-92b8-3fdb0eb270c5').getKey(0))

 

it showed me: 'javaScriptMessage'

 

 

The same you can find in the ScriptListenerJS.log code after running some script from File / Scripts:

 

(dsc = new ActionDescriptor()).putString(stringIDToTypeID('javaScriptName'), 'someItem')
dsc.putString(stringIDToTypeID('javaScriptMessage'), '''undefined''')
executeAction(stringIDToTypeID('AdobeScriptAutomation Scripts'), dsc, DialogModes.NO)

 

Legend
March 25, 2020

I tried this code in several ways, but still did not understand how to check custom option exists in my scripts 😞

(dsc = new ActionDescriptor()).putString(stringIDToTypeID('javaScriptName'), 'someItem')
dsc.putString(stringIDToTypeID('javaScriptMessage'), '''undefined''')
executeAction(stringIDToTypeID('AdobeScriptAutomation Scripts'), dsc, DialogModes.NO)

This code simply runs the script, regardless of whether the settings were saved or not (the main thing is that the script is installed)