How Can I Control a File Open Dialogue Box?

How can I control the File Open dialogue box of a (Java) app and open the document Target.docx on the Desktop?

The dialogue box:

1 Like

It looks like a standard macOS dialog -- if it always opens in the correct folder try an "Insert text by typing" action, using the file name, to select the file then "Keystroke... Return" to open it.

If you want to be explicit about the complete path, then

  1. "Keystroke... ⌘⇧G"
  2. "Pause...0.2s"
  3. "Insert by typing" and eg "~/Desktop/Target.docx"
  4. "Pause...0.2s"
  5. "Keystroke... Return"
  6. "Pause...0.2s"
  7. "Keystroke... Return"

...should do it.

1 Like

At the risk of repeating what Nige has helpfully said, here's a general-purpose subroutine to trigger and fill a Go To dialog, which you can use with any standard macOS Open/Save dialog.

You could then use an "Execute a Subroutine" step in your macro with a parameter of ~/Desktop/Target.docx

Some of the pauses may seem quite long, but these are what I've settled on after a few months' of use to make it consistently reliable.

1 Like

FWIW, I script Default Folder X for this sort of thing. Works perfectly, whereas I saw some inconsistent behaviour with the native keyboard shortcut when used programmatically.

Oooh - thanks (again!), Neil :slight_smile: That might explain why I needed such large pauses.

I have Default Folder X and hadn't realised it was scriptable - will "borrow" your macro :+1:

A while ago, I posted a macro on this topic, which might be helpful.

1 Like

Thank you @Nige_S! I must admit that I wasn't ware of the keyboard shortcut ⌘⇧G :blush: