Hello,
I'm new at applescript and trying to make a file launcher that I plan on eventually expanding, only problem is I can't get it to fill with the proper path! I know in the example below I could probably more easily tell the application to open the file but I plan on using this down the road with a few programs where I don't believe that will work.
Each time I run this I get the following error:
System Events got an error: Cant set window "Open" to "/harmony.xml".
I have tried a few different programs and file types to no avail. I'm running 10.6.2. Any help would be appreciated.
I'm new at applescript and trying to make a file launcher that I plan on eventually expanding, only problem is I can't get it to fill with the proper path! I know in the example below I could probably more easily tell the application to open the file but I plan on using this down the road with a few programs where I don't believe that will work.
Code:
set myFiles to {"File1", "File2", "File3", "File4"}
choose from list myFiles with title "Select File"
if result = {"File3"} then
set filepath to "/harmony.xml"
application "TextEdit" activate
tell application "System Events"
keystroke "o" using {command down}
keystroke "/"
delay 0.5
tell window "Open"
tell sheet 1
set text field 1 to filepath
end tell
click button 1
delay 0.5
end tell
end tell
else
application "TextEdit" activate
end if
Each time I run this I get the following error:
System Events got an error: Cant set window "Open" to "/harmony.xml".
I have tried a few different programs and file types to no avail. I'm running 10.6.2. Any help would be appreciated.