Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

Instead of 'tell process PCSX', it’s probably going to be something more like:

tell application process "PCSX"
    click button "Go" of window "Open"
end

But with GUI scripting, it’s hard to know for certain. I would suggest first finding out how to properly refer to the Open dialog window by trying one of the snippets below. Note that you’ll want to run the snippets below while the window is open.

tell application process "PCSX"
   properties of (every window)
end

or

tell application process "PCSX"
    entire contents
end

From there, get information on the button you want clicked, by using the entire contents command again.

tell application process "PCSX"
    tell window _____
        entire contents
    end
end

Tedious, no? There is also something called UIElementInspector which is a klunky utility by Apple that helps discern the names of interface elements. Much better is the excellent UI Browser http://pfiddlesoft.com/uibrowser/ from PFiddlesoft (what a name).

share|improve this 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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.