[R-SIG-Mac] AppleScript
Gregor Reich
gregor.reich at unibas.ch
Fri Jul 24 19:12:59 CEST 2009
Rob,
Thanks a lot, this works perfectly; at least, with only one instance
of R running. This is rather logical. But nevertheless, since I
regularly use several instances in parallel, I should once do
something about this issue. If anyone has ideas, they are warmly
welcome! Probably something like "last used" / "frontmost" instance.
Just for the protocol, if somebody else is interested as well:
Change
> tell process "SubEthaEdit"
to
tell process "Xcode"
For the keyboard shortcut, you have to go to XCode Preferences and
disable Cmd+Return in the "Build" menu in "Key bindings" for "Build
and Go". Go to the Script menu, choose "Edit user scripts", press the
"+" and "Add new script file". Add your script and the keyboard
shortcut.
Cheers again, Gregor.
> tell application "System Events"
> if UI elements enabled then
> tell process "SubEthaEdit"
> activate
> set frontmost to true
> end tell
> key down command
> keystroke "c"
> delay 1
> key up command
> else
> tell application "System Preferences"
> activate
> set current pane to pane "com.apple.preference.universalaccess"
> display dialog "UI element scripting is not enabled. Check
> \"Enable access for assistive devices\""
> end tell
> end if
> end tell
>
> set y to the clipboard
>
> tell application "R"
> cmd y
> activate
> end tell
More information about the R-SIG-Mac
mailing list