Reputation: 8434
I have never used AppleScript before, but I am trying to write a script that will open Xcode and run the correct app on the correct simulator. Unfortunately I keep stumbling into syntax errors and I am somewhat baffled by the documentation (for a language designed to be like English, it's giving me more trouble than it's worth). I figured out how to open Xcode with the "Activate" command, but am stuck on how to click a specific button. From what I understand I should be able to say something like click button 1 of group 1 of window 1
or something like that, but not only is that giving me syntax errors (as are the many variants I've tried), but also I don't know how to figure out which window is window 1, which group is group 1, etc. I tried using the Accessibility Inspector but couldn't make heads or tails out of it. Can anyone point me in the right direction?
EDIT This is not a repeat of the linked question. That question was about running a build command. I want to actually click buttons in Xcode, and am trying to run the "run" command with the simulator.
Upvotes: 3
Views: 2131
Reputation: 104698
A quick and easy way is to simulate the keystroke:
tell application "Xcode"
activate
tell application "System Events"
perform (keystroke "r" using command down)
end tell
end tell
Upvotes: 9