I think this is possible, because TextMate is doing this. Here’s the command from the CoronaSDK bundle for TextMate:
<?xml version="1.0" encoding="UTF-8"?>
beforeRunningCommand
saveModifiedFiles
command
#!/bin/bash
CORONA_SIM_PATH="/Applications/CoronaSDK/simulator"
# In order for the simulator relaunch to work, “Enable access for assistive devices” must be selected in System Preferences > Universal Access.
osascript <<- APPLESCRIPT
on appIsRunning(appName)
tell application “System Events” to (name of processes) contains appName
end appIsRunning
on selectAppMenuItem(app_name, menu_name, menu_item)
try
– bring the target application to the front
tell application app_name
activate
end tell
tell application “System Events”
tell process app_name
tell menu bar 1
tell menu bar item menu_name
tell menu menu_name
click menu item menu_item
end tell
end tell
end tell
end tell
end tell
return true
on error error_message
return false
end try
end selectAppMenuItem
if appIsRunning(“Corona Simulator”) then
selectAppMenuItem(“Corona Simulator”,“File”,“Relaunch”)
else
tell application “Terminal”
do script “$CORONA_SIM_PATH $TM_DIRECTORY”
end tell
end if
APPLESCRIPT
input
none
keyEquivalent
@r
name
Run Simulator
output
discard
scope
source.lua
uuid
1831E774-8AF9-4EF0-BE93-11B077CC4DC2
[import]uid: 6795 topic_id: 4232 reply_id: 13135[/import]