Select the file needed from an open file dialog window

Hey guys,

I’ve been having a bit of a problem here:
I have an application in which I need to import a file. The problem is that you cannot just select import from the menu at the top, because it is not there. So i looked at some ui scripting and managed to have my script push the import button. Then a file dialog window opens up where i have to select the file(s) (the file(s) will always be in the same directory on the desktop, lets call it SourceDir for now).
So I get the dialog and can click on the folder desktop in the dialog without a problem. Then I have to click on my directory SourceDir. Here is where the problem begins. UI Element Inspector tells me that the values in the listing there are Static Text values.
How can I select the folder I need to select (SourceDir)?

If anyone knows, please tell me.

Thanks

Your question is awfully short on the details necessary to help.

My mistake, I’ll post the code I have already (mind you, that is not much):

A watchfolder has been set up previously and this is the action that will be taken when something is put into it (when copying to the watchfolder has finished). It opens the app Episode Pro, then clicks the “Add Input To Batch” button, no problem there, but then a dialog window opens to select the file(s) you want to add. I then click on the Desktop icon on the left list to make sure I’m looking at the files on my desktop and then I have to select the folder “FolderName” and all items in it. The names in this list (the right list in the file dialog window) are static text and I really don’t know how to select them.
After selecting them, I just have to perform a click on the OK button, but that’s no problem.

I hope this helps clarifying my question.


tell application "Episode Pro" to activate
tell application "System Events" to tell process "Episode Pro" to tell window "Episode - Job Batch"
	--this will click on the "Add Input To Batch" button
	click button "Add Input To Batch" of tab group 1 of group 2 of splitter group 1
end tell
tell application "System Events" to tell process "Episode Pro" to tell window "Add Source File"
	--if you have the watchfolder name stored in a variable, you can use it here to select it. I used the folder "FolderName" on my desktop.
	click button "Desktop" of list 1 of scroll area 1 of splitter group 1 of group 2
	
	select static text "FolderName" of list 1 of scroll area 1 of scroll area 1 of browser 1 of splitter group 1 of group 2
	--The previous statemant returns the right element, the folder "FolderName" on my desktop folder, but it does not select it (and click does not work either)
	
end tell

Greetz

I don’t have Episode Pro, but its features don’t mention scriptability, so I see the reason for your GUI scripting approach.

Aren’t the files you want to add all in your “watchfolder”, so you want all of them? Have you tried keystroking command A to select them all?

Yeah, but the problem is that I have to add them to the program via a button that opens a file dialog (and the dialog window does not open in the watchfolder). So before I can keystroke command-A, I have to navigate to the watchfolder and it is the navigating that does not work.

Got it :rolleyes:. So your question boils down to this: Can I GUI script a standard file dialog (assuming this is a standard system file dialog of the type you’d get with choose folder or choose file)

I don’t know the answer, but it’s an interesting question - I’ll play with it.

That’s it excactly. Have fun playing around ;). I’ll be trying some stuff on it myself too.

I do not have your app but here is an example I have taken from one of my scripts.

tell application "TextWrangler"
	activate
	make new text document
	tell application "System Events"
		tell process "TextWrangler"
			click menu item "Folder Listing." of menu 1 of menu item "Insert" of menu 1 of menu bar item "Edit" of menu bar 1
			keystroke "d" using {command down, shift down} -- gets you to the desktop
			keystroke "Chronos" -- the folder name 
		
			keystroke return -- opens the folder
		
		end tell
	end tell
end tell

so your may look like :

tell application "Episode Pro" to activate
tell application "System Events" to tell process "Episode Pro" to tell window "Episode - Job Batch"
   --this will click on the "Add Input To Batch" button
   click button "Add Input To Batch" of tab group 1 of group 2 of splitter group 1
keystroke "d" using {command down, shift down} -- gets you to the desktop
keystroke "FolderName"  -- the folder name 
	---- other actions 
---- other actions 
end tell