Automate open dialog box

939 Views Asked by At

Is there any way to automate a opening files with open dialog box on Mac OS? The application asks user to open files with the standard open dialog box. But I need open files automatically.

The idea is to write script or a small application which will click the button in the target application to open dialog box and then somehow select files which I needed. But I don't know how can I do it. Any suggestions will be very appreciated.

1

There are 1 best solutions below

2
On

If you already know what file(s) you want to open, then the open file dialog box is usually bypassed completely by the target application.

You'll have to look at the Dictionary for your target application to see if the Open command is defined. If an application is scriptable, then that's going to be one the basics, though each implementation will vary slightly.

If an application doesn't have a Dictionary, you can use the Finder to open the file:

tell application "Finder"
    set theApplication to "Path:To:Application.app" as alias
    set theFile to "Path:To:File.ext" as alias
    open theFile using theApplication
end tell