Scripting a File > Open window

So, I’m trying to navigate through a “File > Open” type dialog using AppleScript, and I’m having a bit of trouble. The main issue I’m having is not being able to click in the File/Folder lists to get to the file I want.

For example, I have a file in a folder on my Desktop that I want to open using a File > Open dialog. I can get the dialog to point at the Desktop, but can’t get it to navigate into the folder to select the file.

From what I’ve been able to sort out on my own, something like this should work:

tell list 1 of scroll area 1 of scroll area 1 of browser 1 of splitter group 1 of group 1 of sheet 1 of window 1 of process "MyApp" to select static text 1

The script executes without error, but it doesn’t appear to select the specified text.

Model: G5 - iMac - MacBook Pro
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi Art;

I think you ought to explain your objective here. It’s usually not necessary to GUI script to open a file, even if it “belongs” to a specific app.

tell application "Finder" to open alias ((path to your folder as text) & "fileName.ext")

I’m trying to set up some automated test scripts for an application I’m working on. I want to make sure that all methods of opening a file work correctly within the application. For some portions of the application the only ways to open a file are via Drag & Drop or through a “File > Open” dialog. I’m not really sure how to do either at this point (I’m still fairly new to AppleScript).

I have a dialog that is separate from the main application. Using the Finder will send the file to the main application (or a different application all together as mine isn’t the default app for this type of file). This dialog has an “Add File” button, which I can click using apple script to bring up this “File > Open” type dialog. I just need to be able to navigate through the "File >“Open” dialog to select a file. I’ve avoided trying to script this type of thing in the past by using the Finder, but I can’t really get around it this time. I know I’m being vague, but I’m not really allowed to go into to much more detail.

From what I can tell by looking at the UI Inspector, the “static text” items in the list columns don’t have any actions associated with them. The PreFab UI Browser’s suggested code for what I want to do offers the code I included previously, it just doesn’t seem to do anything.