How to open a file using Applescript

applescriptdialog

Seems to be a very simple question, but i cannot find the answer in the many many documentation that is around on Applescript.

I have a non-scriptable application for which i want to open a file using the File Open dialog in the application. This is what i came up with so far:

tell application "CubicSDR"
    activate
end tell

tell application "System Events" to tell process "CubicSDR"
    set position of window 2 to {-1920, -296}
    set size of window 2 to {1635, 500}
    click menu item "Open Session" of menu "File" of menu bar 1
    ......
end tell

Then i have tried to select a file, open a file, click a file, nothing seems to work.
This can not be as hard as it seems considering that this is such a common operation.
Does anybody have a code sample i can work off?

Best Answer

Here you go:

tell application "Mail" to open "Library:Desktop Pictures:Small Ripples graphite.png"

Replace "Mail" and the file with the app and file you want to open your file with, respectively.