Cancel a Macro When Typing Text in a Text Field and Then Hitting the "Enter" Key

I have a macro being executed with the hotkey "Enter". I would like to cancel that macro function only when typing text in a type field and it's immediately followed by hitting the "Enter" key. I have tried searching the forum for a solution, but haven't had any luck. Any help is appreciated.

Hey Alex,

You can't do this reliably with any utility available for that Mac that I know of.

Rule-of-the-thumb – never try to use normal typing keys as hotkeys, because you'll always have problems.

There are some special exemptions to this rule. For instance I have several palettes for different contexts that I bring up on demand.

image

The keystrokes are only available when the palette is open, so I have a visual cue that normal keyboard operation is altered.

-Chris

Hi Chris,
Originally I created this execution in Apple Script and that's how it is being performed now in KM. I could always implement an "if else" statement in the script.

Thanks, A

My Mac's Keyboard has both an Enter and a Return key. Perhaps you could consider placing the macro on one of them, and leaving the other one unmacro'd. It's not what you asked for, but it's an alternative that might be worth it.

I know it's possible to do this because the app I am using it in allows you to do it already but the app's shortcut key only executes 1 command at a time. The application is smart enough to know the difference between someone typing and then hitting "Enter" to save the filename and executing the shortcut key when not typing.

That's the app monitoring itself – NOT the macOS monitoring the app.

That's a whole different kettle of fish...

-Chris

There is already a topic on the text field being focused.
https://forum.keyboardmaestro.com/t/can-i-check-if-i-am-in-a-text-field/7251/9

Here's my current script which is inserting "true" after I rename the file and press "enter". How do I
get it to just save the filename I type?
Screen Shot 2022-03-14 at 5.48.54 PM

tell application "System Events"
	
	tell application process "Capture One 20"
		
		set frontmost to true
		
		tell (first window whose subrole is "AXStandardWindow")
			try
				set subjElem to (first text field of scroll area 1 of group 2)
				set subjProp to properties of subjElem
				set subjFocused to focused of subjElem
				return subjFocused
			on error
				tell application "Capture One 20"
					begin live view
				end tell
			end try
		end tell
	end tell
end tell

Try getting the value of subjElem.