Interact with my panel while modal dialog is active

Explorer ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

Hello again!

Here

I describe nearly my workflow while batch editing photos with droplet:

 

  1. By the name of the folder with special tags, the script determines the required aspect ratio and print format.
    2. A cropping dialog opens, in which I can adjust the cropping frame depending on the scene in the photo.
    3. A modal window of curves opens, which I can also correct.
    4. The image is resampled according to the required print size.
    5. The photo is saved with the parameters specified in the script and closes...
    ..then the droplet calls the next photo and everything starts again.

 

And thanks to Kukurykus found solution for one of my problem.

But I have one more 🙂 , and hope I will found solution for this one too.

So.. Then photos processed in droplet, some of them have some non-standard flaws requiring mandatory manual fixes, not amenable to any software solutions. (e.g. red-eye, unfortunate lens flare that looks like specks of dust or a real dust on scanned images etc).

At this time, I use "Cancel" button then curves edit, thus canceling the editing of the current photo and these "canceled" photos remain open in Photoshop untill the entire droplet package has been processed, and then I can edit it manually. 


Ideally, I'd like to be able to tag these photos in some way when I have the curves edit dialog open or when the image crop dialog is open. I was thinking about creating some kind of temporary file in which the path of images needed for "manual-processing" would simply be written in a column, so that after the completion of the entire droplet package, these images, according to the list in the temporary file, could be loaded into photoshop for manual processing.


I created a CEP panel and successfully learned how to create and edit lists of variables. However.. no panel mode that allows me to interact with its elements at the moment when the modal curves or cropping dialog is open.
Conversely, if I make my panel a modal window while it's open, I won't be able to use photo editing tools (action/script/curves/cropping, etc).


However, I see that many of the native elements in Photoshop's interface are still available for interaction even if the curves or editing dialog is active. For example, the panel selection in the Window menu or the Share button in the upper right corner of the Photoshop window... as well as the Action panel and its controls. In addition, if debugging is enabled for my panel, I can interact with elements of my panel in the debug window and activate script execution even if the curves or framing modal dialog is open at this moment.

And this gave me the idea that it is probably still possible in some way to make it possible to click on a button in my panel or register a hotkey press even if the modal curves or cropping dialog is open?

Maybe somebody faced with a similar need and came up with a solution to this paradoxical problem?
Once again, I want to draw attention to the fact that I understand the importance of not violating the order of interaction of modal dialogs with windows and panels located UNDER them, but in my case, I do not need to break the "lock" of the image state, but only need to get its path / name and run the function writing this data to a file.

Thanks!

Here my manifest.xml

If need, i upload my html/js files

<?xml version="1.0" encoding="UTF-8"?>
<!-- 1 -->
<ExtensionManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ExtensionBundleId="com.printprep" ExtensionBundleVersion="1.0.0" Version="9.0">
   <!-- 2 -->
   <ExtensionList>
      <Extension Id="com.printprep.panel" Version="0.0.1" />
   </ExtensionList>
   <ExecutionEnvironment>
      <!-- 3 -->
      <HostList>
         <Host Name="PHSP" Version="20" />
         <Host Name="PHXS" Version="20" />
      </HostList>
      <LocaleList>
         <Locale Code="All" />
      </LocaleList>
      <RequiredRuntimeList>
         <!-- 4 -->
         <RequiredRuntime Name="CSXS" Version="9.0" />
      </RequiredRuntimeList>
   </ExecutionEnvironment>
   <DispatchInfoList>
      <Extension Id="com.printprep.panel">
         <DispatchInfo>
            <Resources>
               <!-- 5 -->
               <CEFCommandLine>
                  <Parameter>--enable-nodejs</Parameter>
                  <Parameter>--mixed-context</Parameter>
               </CEFCommandLine>
               <MainPath>./index.html</MainPath>
            </Resources>
            <UI>
               <!-- 6 -->
               <Type>Panel</Type>
               <!-- 7 -->
               <Menu>Подготовка к печати</Menu>
               <Geometry>
                  <!-- 8 -->
                  <Size>
                     <Height>225</Height>
                     <Width>270</Width>
                  </Size>
                  <MinSize>
                     <Height>165</Height>
                     <Width>250</Width>
                  </MinSize>
                  <MaxSize>
                     <Height>5000</Height>
                     <Width>5000</Width>
                  </MaxSize>
               </Geometry>
               <Icons>
                  <Icon Type="Normal">./images/icon.png</Icon>
               </Icons>   
            </UI>
         </DispatchInfo>
      </Extension>
   </DispatchInfoList>
</ExtensionManifest>
TOPICS
Actions and scripting , Windows

Views

97

Likes

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

correct answers 1 Correct answer

LEGEND , May 05, 2022 May 05, 2022
I thought you want to detect Shift by Plugin command as you were saying of registering it, that is I did not suggest to you ExtendScript code I see now you ended up with yourself: ScriptUI.environment.keyboardState.shiftKey I came with .name instead of .fullName, as you were saying of one of two properties in your first post, and when using it with limited getenv characters row, it was safer to use shorter items than full paths. The other thing I did not mention to not complicate was a need ...

Likes

Translate

Translate
LEGEND ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

 

//	when documents remain open, take them to memory:
dcmnts = [].slice.call(documents), fls = []; while(dcmnts.length)
	fls.push(dcmnts.shift().name); $.setenv('fls', fls.toSource())

//	next time, when already closed, access their names:
fls = eval($.getenv('fls')); while(fls.length) alert(fls.shift())

 

Likes

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
Explorer ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

Thank you for reply!
As I understand, this script must create array from all current opened documents names and  then with

eval($.getenv('fls'))

I can recall all saved documents? This can be need for me too.. but...

What I want (and now I realize what I dont mentioned this, sorry) is dont cancel processing, and perform crop/curves/save/close till the end, for any image in droplet... but at the same time, make a list of images that require manual processing, so that at the end I have an empty photoshop and a list of those images that I need to reopen for process them manually.
And the main problem here is that while executing the script in the droplet, I do not have the ability to interact with the photoshop interface (including my panel) in order to add files to this list in any way(press button use hotkey).

I'm not sure if I described correctly.. understand me? I'm sorry, but my English skills are still far from the best and I have to translate a lot with the help of Google. 

But I think I've come up with something... Now I'm checking to see if it's possible to register the shift key press when I press OK in the curves dialog. And I think I have almost got the desired result. With your code for creating an array of documents, I can probably even do without a temporary file.

Likes

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 05, 2022 May 05, 2022

Copy link to clipboard

Copied

Previously you were cancelling images when found they need some retouching, now you want to continue the process to its end without breaking it for single photos. Still as you've noticed you can use my method, with Shift key pressed if detected at time of closing the dialog. Just make sure the array assigned to environment variable is not created yet. If so let script create it only once, then push name of document to an array. At any next turn when array is already created you only push another names to it. Additionally set variable to undefined by using following line at beginning of script: $.setenv('fls', '')

Likes

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
Explorer ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

quote

Previously you were cancelling images when found they need some retouching, now you want to continue the process to end without breaking it for single photos.


By @Kukurykus

 

I'm sorry... my fault. I didn't finish my thought by describing my process in the first post, and because of that, an important point was missed.
But in the end it all worked out and thanks to your hint, it turned out more elegantly than I originally intended.
Perhaps you will have some comments on the code in my previous message, I will be glad if you correct me.

Thank you very much in any case!

Likes

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
Explorer ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

Yes. I was able to register the shift key pressed while pressing OK in the curves dialog. And now in function what open curves, I add function addFileToPost(). Now, thanks to this, I can press Shift while saving the curves, and add the current image to the "collection" of those that need manual processing later.

 

function curvesOpen () {
    try {
        dsc = getCustomOptions('curves')
    } catch(e) {
        dsc = new ActionDescriptor()
    }
    try {
        dsc = executeAction(stringIDToTypeID('curves'), dsc, DialogModes.ALL), putCustomOptions('curves', dsc, false);
        addFileToPost ();
    } catch(e){
        if (e.message == 'User cancelled the operation') alert('Curves canceled!'+'\r\r'+'Press OK.', 'Cancels');
        else alert(e);
        return false;
    }    
    return true;
}

function addFileToPost () {
    var shiftTrue = ScriptUI.environment.keyboardState.shiftKey;
    if (shiftTrue) alert(File.decode(activeDocument.fullName));
    filesToPost.push(activeDocument.fullName);
    if (envFilesToPost = eval($.getenv('filesToPost'))) {
        while(envFilesToPost.length) filesToPost.push(envFilesToPost.shift())
    }
    $.setenv('filesToPost', filesToPost.toSource());
    envFilesToPost = eval($.getenv('filesToPost'));
    while(envFilesToPost.length) alert(envFilesToPost.shift());
}

 

 

Likes

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
Explorer ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

Cant edit my post... (maybe moderators can did it and then delete this post)

Ofcause in function addFileToPost() if statement must be for all further code.

 

function addFileToPost () {
    var shiftTrue = ScriptUI.environment.keyboardState.shiftKey;
    if (shiftTrue) {
        filesToPost.push(activeDocument.fullName);
        if (envFilesToPost = eval($.getenv('filesToPost'))) {
            while(envFilesToPost.length) filesToPost.push(envFilesToPost.shift())
        }
        $.setenv('filesToPost', filesToPost.toSource());
        envFilesToPost = eval($.getenv('filesToPost'));
        while(envFilesToPost.length) alert(envFilesToPost.shift());
    }
}

 

Likes

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 05, 2022 May 05, 2022

Copy link to clipboard

Copied

I thought you want to detect Shift by Plugin command as you were saying of registering it, that is I did not suggest to you ExtendScript code I see now you ended up with yourself: ScriptUI.environment.keyboardState.shiftKey

 

I came with .name instead of .fullName, as you were saying of one of two properties in your first post, and when using it with limited getenv characters row, it was safer to use shorter items than full paths.

 

The other thing I did not mention to not complicate was a need of decoding, fortunately you were enough smart to use. In my case that would be same working: decodeURI() method.

 

There's no declaration of filesToPost in your code, so perhaps you used it only in your other code, anyway it's better to use this construction (I didn't try so maybe there's mistake):

 

//	only once:
$.setenv('fls', '')

//	each time you keep Shift pressed:
fN = decodeURI(activeDocument.fullName)
if (!(str = $.getenv('fls'))) $.setenv('fls', [fN].toSource())
else (arr = eval(str)).push(fN), $.setenv('fls', arr.toSource())

 

If that's not correct, correct it and mark some answer(s) as correct as well 😉

Likes

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
Explorer ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

LATEST

Thanks again! Too bad I didn't ask for help on this forum a few years ago. Would save a lot of time for learning English 🙂

Your code work like a charm, so I used them! Ofcause marked answear as correct!

 

as you were saying of registering it

 

And again sorry... I try my best to explain myself, but it doesn't always work out.

 

There's no declaration of filesToPost

 

Yes.... i was thinking of declaring it at the very beginning of the script, but with your code example, this is no longer necessary.

Likes

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