Copy link to clipboard
Copied
I Want To Make (Esc Key) ..not working while running script ..how can i make this ?
Copy link to clipboard
Copied
As far as I know the ESC Key can be used to Break/stop a running scripts execution. The script's execution will be terminated. Where in the script execution is it terminated would be unknown and a script could have opened many document or closed all open documents. If you want to terminate a particular script and close a document it has been working on because you can see that processing has gone south. I would thing you would need to program that capability into to the script. You would have to set some way that you can signal the script to close the document and end execution. I do not think you can do the using the ESC key. Except in ScriptUI but with ScriptUI it would be just as east to set up a stop button. ESC in ScriptUI is like a cancel event.
Copy link to clipboard
Copied
The other thing with the esc key is that it will terminate the script, but if Photoshop has not caught up with the script, it will seem like it keeps on running. This happens with you have a loop. The script will have run the loop, but it will take Photoshop a long time to catch.
Copy link to clipboard
Copied
how can i make function on Esc key to close current file..please write javascript
Copy link to clipboard
Copied
Some thing are not possible
Copy link to clipboard
Copied
You should be able to catch the user cancel. This is how Image Processor.jsx does it:
Depending on your operation it is difficult to capture the ESC key however. Your mileage may vary.
// Lot's of things can go wrong
// Give a generic alert and see if they want the details
catch( e ) {
if ( e.number != 8007 ) { // don't report error on user cancel
if ( confirm( strSorry ) ) {
alert( e + " : " + e.line );
}
}
gScriptResult = 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
}
We have also added a progress bar via the application: Here is an example:
var d;
// doForcedProgress("Testing", "Testing()");
doProgress("Testing", "Testing()"); // this waits 3 or so seconds before showing
function Testing() {
try {
if (documents.length == 0)
d = documents.add();
else
d = activeDocument;
var keepGoing = true;
for (var i = 0; i < 100 && keepGoing; i++) {
keepGoing = doProgressSubTask(i, 100, "DoIt()");
}
if (!keepGoing)
alert("User canceled");
} catch(e) {
alert("Testing: " + e);
}
}
function DoIt() {
try {
d.artLayers.add();
}
catch(e) {
alert("DoIt: " + e);
}
}
Copy link to clipboard
Copied
I think what Tom means (Tom correct if I'm wrong) To catch the ESC cancel you need be in a try that has a catch designed to catch the ESC cancel and do something about it.. Often try code may use functions which may have try catch code that the catch may simply throw away the ESC cancel and the script will keep on running. In other word handling the an ESC key cancel can be a problem. It can happen any place in the script and Murphy states that it will. You must be prepared at all times to catch the ESc and have some plan to do something about it and forget not that some vital code in the Try may have been skipped caused by the catch trigger. Your mileage may vary.
IMO It would be easier and safer to devise some kind of signal that the script would look for repetitively in its processing to see if you want it to stop cleanup and exit. The signal may be done from outside of Photoshop. For example the Script Could create a file on the users desktop named Delete me and I script name will stop. The script would continue processing till done or the file !exists. The test would be made at logical stopping point in the processing loop.
Copy link to clipboard
Copied
there's an error
doProgressSubTask :- is not a function
Copy link to clipboard
Copied
What version are you using? You need CC 2015 or later.
Copy link to clipboard
Copied
i`m using phototshop cc 2014
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more