• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

UI Script Remember Last User Value Entered

Engaged ,
Apr 12, 2020 Apr 12, 2020

Copy link to clipboard

Copied

The UI has 4 radio buttons and 4 editable text input fields. The editable fields have a default value "Edit Text". The objective is that the user enters a custom value in the text input field and runs the script.  

 

Screen Shot 2020-04-12 at 8.57.11 AM.png

 

1)  Can a jsx script remember the last text input value used so that the next time the UI dialog runs the value appears in the text input field?
2) Allow the user to reset the dialog text input field to the default value.
3) What are the jsx functions that allow this behavior?

 

The idea is:
if the text input value is not equal to the default value,
the new text input value becomes a temporary variable,
the temporary variable becomes the default text input value,
then the user clears the temporary variable,
if the temporary variable is empty,
the script returns to the default text input value
TOPICS
Actions and scripting

Views

2.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Apr 12, 2020 Apr 12, 2020

Copy link to clipboard

Copied

Play with putCustomOptions(), getCustomOptions() and eraseCustomOptions().

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 12, 2020 Apr 12, 2020

Copy link to clipboard

Copied

Thank you for providing the functions. Can the getCustomOptions() get the name of an action Set and action from the Actions Pallet?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

Look at the scripts that come with Photoshop. Getting list of actions is well written in the image processor.jsx

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

Thank you for the suggestion. I looked at the imageprocessor.jsx and had a difficult time making sense of the long script. Are there any simple examples of how to display the action set and actions in a dialog UI window?   

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

No it can't. But it can remember last user value entered (optionally when Photoshop is relaunched).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 12, 2020 Apr 12, 2020

Copy link to clipboard

Copied

This will remain even if you restart InDesign.

//save
app.insertLabel("foo", myString);
//load
var myString = app.extractLabel("foo");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 12, 2020 Apr 12, 2020

Copy link to clipboard

Copied

Thank you will try in Photoshop.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 12, 2020 Apr 12, 2020

Copy link to clipboard

Copied

I'm very sorry, I mistaken for InDesign because I had multiple windows open.
I don't think there is any other function that can hold the value even after restarting the application. It may be necessary to read / write to a text file with invisible attributes.

By the way, to get the action set and the action name surely, the description by the action descriptor obtained by ScriptListener should be indispensable.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

Yes, there is such function that holds data after relaunching Ps. It's that I mentioned in this thread.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

That's the same that customOptions does in Photoshop.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 24, 2020 Jun 24, 2020

Copy link to clipboard

Copied

Hello Kukurykus,

I have a similar question. I'm entering a value manually in the Median filter with DisplayAllDialog True: lets say 12. Then I accept this value. The second time around i want to repeat this action with the same value entered by the user but this time with DisplayNoDialog. How would one query the last entered value with descriptors? I'm doing this in Python but a js equivalent would help me figure this out.

def apply_median(median_value, open_dialog=False):
    action_name = apply_median.__name__
    action_manager = ActionManager(action_name)
    with action_manager as am:
        s2t = am.convert_id
        app = Dispatch("Photoshop.Application")
        desc_13 = am.gen('descriptor', 'desc_13')
        dialog = None
        if open_dialog:
            dialog = am.dialog_mode_all
        else:
            dialog = am.dialog_mode
        desc_13.PutUnitDouble(s2t('radius'), s2t('pixelUnit'), median_value)
        app.ExecuteAction(s2t('median'), desc_13, dialog)
    print(f'{action_name=} executed')

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

LATEST
executeAction(stringIDToTypeID('median'))

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

//input variables
var settingsNameUniqueString = 'your script name',
text1 = 'sample text 1',
text2 = 'sample text 2',
text3 = 'sample text 3'

//saving settings
var d = new ActionDescriptor
d.putString (s2t('t1'), text1)
d.putString (s2t('t2'), text2)
d.putString (s2t('t3'), text3)
app.putCustomOptions (settingsNameUniqueString, d)

//reading settings
var d = app.getCustomOptions (settingsNameUniqueString)
alert (d.getString (s2t('t1')))
alert (d.getString (s2t('t2')))
alert (d.getString (s2t('t3')))

function s2t(s) { return app.stringIDToTypeID(s) }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

Hello, I'm not sure if the file info part of Photoshop is a JSX found somewhere, but they implemented the same function recently.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 24, 2020 Jun 24, 2020

Copy link to clipboard

Copied

I do this by saving an XML file with settings, that way I can store whatever I want. Defaults are hard-coded.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines