Check if Text Input Is Active

For some odd reason (maybe this is a Catalina bug, I don't know) when I open the Save window, I guess on pretty much all apps, the field to type the name of the file is 4 times active/focused like this:

Screen Shot 2023-01-21 at 10.58.29 AM

But then the 5th time, it's not:

Screen Shot 2023-01-21 at 10.57.21 AM

So if I want to quickly rename the title, I have to move the mouse and click the field. It's a bit annoying, because I never know when it's going to be active.

Is there a way for KM to know if a certain field is active/focused and if not, perform a certain action?

I can't replicate this behaviour here. Might seem a silly question, but is there any chance you're accidentally hitting another key after ⇧⌘S, or do you have another macro you've forgotten about that's interfering?

One thing you could try is to always click that field, regardless of whether it's pre-selected. For example:

  • Trigger by front window change
  • If front window name contains "Save"
    • Then click name field (via offset Found Image) and simulate ⌘A
  • Else do nothing
2 Likes

No, this is something that happens all the time, with many different apps. It's been like this since I remember buying this computer and having Catalina, that's why I was assuming it could be a Catalina bug.

I was thinking about that work around you suggested, but I wanted to know if there was another way besides that. I believe I have some macros that do that, as you said.

It's such a weird "bug"...

The macro will need to have a trigger, so if you don't want to use front window changes, you could try:

Trigger by ⌘S or ⇧⌘S
Pause until front window title contains "Save"
Click name field (via offset Found Image) and simulate ⌘A

Of course this will only work when saving via those shortcuts (i.e. not when using the mouse or when an app asks if you want to save before quitting).

Hey Danny,

I don't recall hearing about this one when Catalina came out, so I don't think it was a widespread thing. I'm still using Mojave myself and will jump farther up the chain when I upgrade my hardware.

With this sort of problem I like to work as much as possible with the macOS where it is consistently possible.

On the whole I agree with Neil's proposal, but I wouldn't use a click.

  • Override Save with a hokey trigger – ⌘S.
  • Pause until Save button exists.
  • Type ⌘F to move to the Find field.
  • ⇧Tab, ⇧Tab to move back into the Save As: field.

I myself would do this with AppleScript UI-Scripting instead of working the UI, but that's too complicated for most folks.

-Chris

1 Like

Much better!

1 Like

Unfortunately this won't work for me, because CMD+F for me is what I use to trigger another app, PlugSearch, and so when I hit CMD+F while on the Save As window, it opens PlugSearch, it doesn't move the cursor to the Find field...

It would be a good workaround for sure though. Thanks for sharing!

Change it to Cmd-Opt-F or Cmd-Shift-F.

Using Cmd-F is going to be your simplest, most bomb-proof means to do what you want.

If you refuse to do that then you'll have to depend upon found images or something else.

This works on my system for Google Chrome and TextEdit Save dialogs. It sets the user-focus back to the “Save As:” field.

But it might require adjustments to work on later versions of macOS and possibly with other apps.

tell application "System Events"
   tell (first application process whose frontmost is true)
      tell (first window whose subrole is "AXStandardWindow")
         tell sheet 1
            tell text field "Save As:"
               set focused to true
            end tell
         end tell
      end tell
   end tell
end tell