Action or javascript; how to program "escape key"

Participant ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

Hi,

I am looking for to way to add an Action event or javascript to program an "escape key" event.

 

I need to exit Ps edit boxes (opacity, flow, etc...) and/or exit Free Transform before the rest of my Action/Javacript executes.

 

Manually pressing the ESC key (Mac) does exactly what I want, but I would like to do this programmatically as part of an action or javascript.

...TIA for looking

TOPICS
Actions and scripting

Views

223

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
Community Expert ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

Only the Free Transform seems of interest to me and I am not sure I understand the issue. 

Do you want to allow for user interaction? 

If so the user pressing enter to confirm the transformation seems perfectly reasonable and that can be done when executing the AM-code of the operation with »DialogModes.ALL«. 

 

Maybe you should explain what you are actually trying to achieve and post screenshots to illustrate. 

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
Participant ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

1. I print a lot and resize the canvas a lot. My action finishes with Free Transform, ready for me to resize the layer. If I want to run another action to resize the canvas, I must manually hit excape first. If I don't escape Free Trasform active, my actions won't run, I get a beep. Note: I am in Actions; Button mode.

; I would like to Escape (exit Transform). Escape otherwise is benign or has no ill effects. Alternatively I would like to Reset Transform as long as it exits also.

 

2. Having clicked in an edit box such as; opacity, flow etc. I just don't want unpected values when I execute an action/javascript to set the brush size. Pressing escape key assures that. But I would like program that -- call me a control freak. 🙂   

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
Community Expert ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

Sorry, I may still not understand the issue. 

 

Presumably you enabled user input for the transformation by clicking the »Toggle dialog on/off«-button in the Actions Panel. 

So user input would be necessary by your own choice, whether it is manual transformation and hitting enter (or double-clicking …) or hitting esc. 

 

That an Action cannot be run if another Action is still running seems to be as expected to me. 

 

Maybe a more meaningful process would be viable via Scripting, though I am not sure what the whole process is supposed to encompass. 

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
Participant ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

Suffice to say I am trying to idiot proof my actions / scripts. If an employee (prepress) is resizing a photo manually (free form), doesn't like the aspect ratio or format, thus, he doesn't commit the Freeform change. Now he/she wants to change the canvas size (with an action) -- he can't. The freeform tool is active and doesn't allow exectution of the action. He has to hit escape first or gets a BEEP. This happens 30x a day, so I am trying to idiot proof my action -- just put an Escape at the begining. An escape keypress is otherwise benign. In Photoshop, we should be allowed to exit freeform tool programmatically just as we can with "deselect"...

 

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
Community Expert ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

Two Actions cannot run simultaneously (at current). (edit: though running one Action can be recorded into another but that has no bearing on this issue, I guess)

The esc in the second has diddley squat to do with the first. 

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
Participant ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

Sorry, I am not making myself clear. I am not trying to run actions simultaneously.

Process;

1. user clicks action to change aspect ratio, canvas size.

2. user clicks freetransform to fit

3. user decides it is the wrong aspect ratio and wants to click another action to change aspect ratio

Either the user hits escape then runs another action (a different aspect ratio)

Or, user forgets to hit escape and gets a BEEP.

I just want to program an escape at the beginning of the action (could be jsx) or deselect the Free transform or whatever, so the user can have an uninterupted workflow... 

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
Participant ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

I am not wanting to manually press Return (commit) the free transform, these are big files and the commit takes a second or two. I just want to tap my actions (canvas size) one after the other with Free Transform active -- but not have to escape manually in between Actions becuase Free Transform prohibits running actions.

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
Community Expert ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied


@contactzero wrote:

I am not wanting to manually press Return (commit) the free transform, these are big files and the commit takes a second or two. I just want to tap my actions (canvas size) one after the other with Free Transform active -- but not have to escape manually in between Actions becuase Free Transform prohibits running actions.


I see no possibility for this at current. 

If the transformation is part of one Action the next Action cannot be started without the first Action terminating. 

 

If you just want to see the Transformation Handles you could set the Move Tool to »Show Transform Controls«. 

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
Participant ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

Nope, I may have said transform is part of the action but that is incorrect, It is part of the manual process inbetween actions running. But in a hurried workflow and not wanting to commit a Free Transform, the employee just clicks another action, change canvase size or aspect ration and can't because the Free transfrom is active.

 

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
Community Expert ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

I see no possibility for this at current. 

Unless the operation (transformation in this case) is terminated further input (like starting an Action) is not possible. 

 

You may need to restructure the workflow. 

Is manual tranformation really the best choice? Might numeric transformation (in a custom dialog, not in the Options Bar) provide a better experience to your co-workers? 

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
Participant ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

The image must always be manipulated somewhat. Imagine a 4:5 format image being slid around behind a matte frame for a canvas format 3:2. You expand the original photo beyond the matte, most always off center of the original image center. Then crop. The crop is visual and cannot be calculated. The action part is clicking the canvas size and matte border width... Having the Free Transform always ready IS the better experience; I want to turn Free Transform OFF at the beginning of the action, and back ON again at the end of the action/script. The experience would be invisible to the employee and ready the Free Transform each iteration; action/script, transform, action/script, transform. Instead of; action/script, transform, Beep, oh yeah, Esc, action/script, transform.

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
Participant ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

LATEST

Also imagine I just found out the REAL PROBLEM; the employee manually HIDES the Free Transform grab bars while moving the image under the mask to better visualize the result. There is no action or script running at this point. But when the employee wants to run a script / action -- BEEP, he can't. Thus, the frustration of why won't the script run! The Free Transform is active but he doesn't see it, thus doesn't press escape. Fuuuu... Ps really needs a "DeSelect" for Free Transform.

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
Engaged ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

I can't think of a way to catch the ESC key in an Action, but in ExtendScript (JavaScript) you can...

if (ScriptUI.environment.keyboardState.keyName == "Escape") {
    // ESC key has been pressed
}

 

William Campbell

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
Participant ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

I'll look into this... I'm not trying to TRAP the escape, I'm trying to programmatically make the kepress escape - in Photoshop. And I understand this is a security issue and that's why this is difficult.

 

The fault lies within PS for not having a menu command "deselect" method for Free Transform... -- Other than the ESC escape key.

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
Engaged ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

OK pressing the key, not detecting if it's pressed. That's different. I haven't tested this, and I'm not positive of all the values, but this should point you in the right direction. See the Creative Cloud JavaScript Tools Guide page 152 for more about this. https://download.macromedia.com/pub/developer/aftereffects/scripting/JavaScript-Tools-Guide-CC.pdf

initKeyboardEvent() eventObj.initKeyboardEvent (eventName, bubble, isCancelable, view, keyID, keyLocation, modifiersList)  

I'll guess the eventName is either "keydown" or "keyup". keyID is probably "Escape" like the other code. Just guessing though. Do some experients and see what you can learn.

 

William Campbell

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
Participant ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

Thank you. I'll look in this direction..

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
Enthusiast ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

From a "big name" scripter, I have the quote, "It’s not possible to send keys with a PS script."

I think I do understand the problem, as I try a lot of this cool stuff myself.

I use an external helper for some of this (for PC that would be a small AutoIt.exe that's running in the background, although sometimes I open another one from within an action.).

I will give one example that might help you. Let's say you have F1 programmed as your Run/Continue key for actions (that's what I do). Now, in your helper app you could catch the F1 key and do something else first, like ESC.

To put it very simply, F1 would call this function...

 

Func F1_was_Pressed()								; 	 
 If WinActive("[CLASS:Photoshop]") Then
    Send("{ESC}")										 				 
    Sleep(300)
    Send("{F1}")
  EndIf
EndFunc

 

This can of course cancel out things when you don't want it to..., so further thought or intelligence could be needed. Probably not handy on a key you use all the time, like Run/Continue, but on a key that saves your document, for example (to make sure you have left all fields and the key actually engages).

 

To have someone clicking on an action would be different though... If these actions are always in the same spot, maybe you could have the helper app go to a function depending on where you clicked on the screen. It could possibly intercept the click, do ESC first, then send the real click that runs the action underneath. I'm 99% sure this is possible with this kind of software, and I'm probably doing it somewhere.

For some UI elements, you can detect and decide based on the internal code for that element. This makes it possible to deselect a field, do something, then make that field active again, for example.

In my Mac days 25 years ago, I used QuicKeys. I don't know what's the best one at the moment...

Update:
I just checked if AutoIt can pick up an individual ID or text for each action button, and seems it can't — just cursor coordinates and the color underneath (meaning, your critical actions would have to be in a ±exact spot for the coordinates method to work).

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
Community Expert ,
Aug 07, 2022 Aug 07, 2022

Copy link to clipboard

Copied

@contactzero  Perhaps a .confirm() and conditional script step could offer the choice of running the free transform or to play the canvas action instead? This way you avoid the issue of having the transform already set and then needing to escape it.

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