MacOS – Applescript Click “Go” and “Open” – dialog inside application

applescriptmacos

In PCSX, (ps1 emulator), I'm trying to automate the steps to play an ISO. So, I'm doing this:

set thepath to path to me
set thesecondpath to POSIX path of thepath
set thethirdpath to "Contents/PSX/ROMS/img.bin"
set thefourthpath to "/Contents/PSX/PCSX.app"
set thefifthpath to thesecondpath & thefourthpath
set theultimatepath to thesecondpath & thethirdpath

tell application thefifthpath
    activate
    tell application "System Events"
        keystroke "i" using {command down}
        keystroke theultimatepath
        delay 1.0
        tell process "PCSX"
            click button "Go"
        end tell
        key code 53
    end tell
end tell

Running from the AppleScript Editor won't work. I made it to work running from the App it creates. PCSX and the img.bin are inside the Generated Package.

after pressing command+i, it opens a "Go to the folder" dialog, and I need to click Go and then Open

Check it out here

But doing this way, it won't find the dialog box. What am i doing wrong?

Best Answer

Try something like this:

activate application "TextEdit"
tell application "System Events"
    keystroke "o" using command down
    keystroke "g" using {shift down, command down}
    tell window 1 of process "TextEdit"
        set value of text field 1 of sheet 1 to "/usr/share/dict/connectives"
        click button 1 of sheet 1
        click button "Open"
    end tell
end tell