1
votes

Want to send text from any application to "Sublime Text 3" and this is how I am thinking of doing it

  • Create an "automator" service
  • Set a shortcut for it
  • Call shortcut from app

I am able to create the "automator" service and it works fine when tested from within "automator" (by means of the "Get Text" action)

But, when I trigger shortcut from application, "Sublime Text" does not open new tab with the selected text (and does nothing)

This is how I am setting up the "automator" service

  1. Service receives selected text in any application
  2. Copy to Clipboard
  3. Run this applescript

    on run {input, parameters}
    
        tell application "System Events"
            set frontmost of process "Sublime Text" to true
            tell application "System Events" to keystroke "n" using command down
            tell application "System Events" to keystroke "v" using command down
        end tell
    
    end run
    

Appreciate the help, thanks

1

1 Answers

1
votes

The following example AppleScript code works for me:

on run {input, parameters}
    tell application "Sublime Text" to activate
    delay 1
    tell application "System Events"
        keystroke "n" using command down
        delay 0.5
        keystroke "v" using command down
    end tell
end run

Note that the value of the delay commands may or may not need to be adjusted for timing on your system.