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

Action to run script with dialog box shown only once.

Explorer ,
Oct 29, 2017 Oct 29, 2017

Hello,

I need to create an action, that runs the script. This script displays a dialog box, with various variables for user to select.

When I choose Automate > Batch and select this action, the dialog box appears for every image.

Is there any way to show the dialog box only once and apply the variables values set within this dialog box to the whole batch of images I want to process?

Thank you!

TOPICS
Actions and scripting
1.2K
Translate
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
People's Champ ,
Oct 29, 2017 Oct 29, 2017

You can use get_run_counter() set_run_counter() or _get_run_counter() _set_run_counter() functions to determine the number of script starts since the start of the photoshop.

///////////////

var options_name = "My Options";

alert (get_run_counter())

inc_run_counter();

alert (_get_run_counter())

_inc_run_counter();

////////////////////////////////////////////////////////////////////////////////////////////

function get_run_counter()

    {

    var d = null;

    try { d = app.getCustomOptions(options_name); } catch(e) { d = null; }

  

    if (!d) return 0;

    return d.getInteger(0);

    }

////////////////////////////////////////////////////////////////////////////////////////////

function inc_run_counter()

    {

    var cnt = get_run_counter();

    var d = new ActionDescriptor();

    d.putInteger( 0, cnt+1);

    app.putCustomOptions(options_name, d, true);

    }

////////////////////////////////////////////////////////////////////////////////////////////

function _get_run_counter()

    {

    var cnt = $.getenv(options_name);

    if (cnt == null || cnt == undefined) return 0;

    return Number(cnt);

    }

////////////////////////////////////////////////////////////////////////////////////////////

function _inc_run_counter()

    {

    var cnt = _get_run_counter();

    ++cnt;

    $.setenv(options_name, cnt.toFixed(0));

    }

Translate
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
Explorer ,
Nov 05, 2017 Nov 05, 2017

Thank you very much for your suggestion, your solution is helpful but it would require restarting Photoshop after every batch.

Translate
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 ,
Oct 29, 2017 Oct 29, 2017

Another option is to call the script with the SHIFT key pressed then you can use..

if (ScriptUI.environment.keyboardState.shiftKey){

    // UI goes here

    }

//rest of code

Then the UI will only be called the first time.

Translate
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
Explorer ,
Nov 05, 2017 Nov 05, 2017
LATEST

Thank you for your reply.

Although it is very clever, I need to call the action via File > Automate > Batch.

Otherwise, I think my script could just use a dialog box to select a folder with images I want to execute the script on.

Translate
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