Copy link to clipboard
Copied
Hello,
When I save changes to a Photoshop document - already saved to disk - with the app.activeDocument.save() command, a progress modal dialog is displayed:
But if I use the Save menu item of the File menu, the recording is done as a background process (without modal progression) and I can continue to work.
So, using extendscript with Photoshop 13 (CS6), how can I save the active document as background process without this annoying modal window?
Thank you.
Copy link to clipboard
Copied
Offhand, I would say this may not be possible, as when you run a script, you can't do anything until the script completes. However, you might want to try recording the save with AM code rather than DOM. Maybe that might work.
Copy link to clipboard
Copied
Thank you for your answers.
@Stephen_A_Marsh: just tried but DialogModes.NO doesn't change anything.
Chuck, I don't understand what is a record with AM. Is it the ScriptListener?
I tried with the code written by the ScriptListener when using the Save menu item but the result is the same: I always have this annoying modal progress window.
Copy link to clipboard
Copied
Thank you for your answers.
@Stephen_A_Marsh: just tried but DialogModes.NO doesn't change anything.
By @fredericm80874937
That's a shame. What happens if you record the save command into an action? A script can play an action...
Copy link to clipboard
Copied
Have you tried something like:
var savedDisplayDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
app.activeDocument.save();
app.displayDialogs = savedDisplayDialogs;
Copy link to clipboard
Copied
This is possible by running an external script (or program) that simulates pressing Ctrl + S, provided that you have the background save mode enabled.
REM: In this case, the script must be in step-by-step mode for some time at the time the external program is launched, otherwise Photoshop will skip processing the keystrokes.
Copy link to clipboard
Copied
OK, I finally wrote an Applescript that launches a Photoshop action, because MacOS makes it difficult to directly call a menu-item.
So I have an extendscript that inserts a history step and then calls the Applescript (which itself calls an action)...
Copy link to clipboard
Copied
@Stephen_A_Marsh I didn't know that a script could perform an action. It can be interesting.
@r-bin indeed, it must be possible but it becomes complicated for what I would like to do.
Maybe I'm doing it wrong and there are other ways to do what I want.
When I save the changes of the active document, I would like a history step to be created (with an extendscript script).
I tried to run the history step creation script with the Scripts Events Manager but there are problems:
- if I run my extendscript on the "start saving" event, the history step is created even if the saving of the document is not completed (error or cancellation by the user). So this solution is not accurate.
- if I run my extendscript on the "saving document" event, the history step is created after the document is saved, and so the document appears as modified (and displays a save modal dialog if I close this document, which is rather painful).
Do you know another way to do what I would like?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@Stephen_A_Marsh I didn't know that a script could perform an action. It can be interesting.
By @fredericm80874937
A script can play an action, and an action can record the execution of a browsed script (that has not been installed) or the insert menu command of an installed script in the presets/scripts folder!
app.doAction("Molten Lead","Default Actions.atn");
// or
var actionName = "Molten Lead"; // Action to run
var actionSet = "Default Actions.atn"; // Action set to run
app.doAction(actionName,actionSet);
// or
playAction ('my action set', 'my action name')
function playAction(actionSet, actionName){
var idPly = charIDToTypeID( "Ply " );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idActn = charIDToTypeID( "Actn" );
ref1.putName( idActn, actionSet );
var idASet = charIDToTypeID( "ASet" );
ref1.putName( idASet, actionName );
desc2.putReference( idnull, ref1 );
executeAction( idPly, desc2, DialogModes.NO );
}
Copy link to clipboard
Copied
@Stephen_A_MarshThank you! I just tried with app.doAction but the result is the same (modal progress window). I think Chuck is right: when running an extenscript, you can't do anything until the script completes, so a modal window is displayed.
It often happens that I try a little "weird" and complex things on the images that I process and I find it useful to have a step in my history: it allows me to see exactly what I have done since the document was last saved. Of course, when I'm not happy with my latest changes, I could use the Revert to Saved menu item, but that might undo actions I want to keep.
This script is not very important, it's just for a better working comfort.
In any case, I can keep the one I currently have: the one with the progress modal window.
(and sorry for my english, I used Google Translation)
Copy link to clipboard
Copied
@Stephen_A_MarshThank you! I just tried with app.doAction but the result is the same (modal progress window).
By @fredericm80874937
Yes, I didn't hold much hope and was hoping for a pleasant surprise.
I think Chuck is right: when running an extenscript, you can't do anything until the script completes, so a modal window is displayed.
He usually is!
Copy link to clipboard
Copied
For windows try this script.
try {
ctrl_j();
ctrl_s();
app.refresh();
alert(1);
for (var i = 0; i < 100; i++) ctrl_j();
alert(2);
////////////////////////////////////////////////////////////////////////////////////////////
function ctrl_s()
{
var ctrl_s_exe_name = "C:\\Program Files\\Common Files\\Adobe\\Scripts\\UTIL\\ctrl_s.exe";
try {
var f = new File(ctrl_s_exe_name);
if (f.exists)
{
f.execute();
f = null;
}
else
alert("File not found\n\n" + f.fsName);
}
catch(e) { throw(e); }
}
function ctrl_j()
{
try {
executeAction(stringIDToTypeID("copyToLayer"), undefined, DialogModes.NO);
}
catch(e) { throw(e); }
}
} catch(e) { alert(e); }
First copy the exe-file https://disk.yandex.ru/d/HktKHYckuPt-eA
to the specified path.
Copy link to clipboard
Copied
Thank you very much!
I would be eager to test this script... If I wasn't working on Mac 😞 (MacOS Sierra 10.12)