在 MacOSX 中,无法让 applescript+automator 服务工作以将文本从任何应用程序发送到 "Sublime Text 3"
In MacOSX, can't get applescript+automator service working to send text from any application to "Sublime Text 3"
想要将文本从任何应用程序发送到 "Sublime Text 3",这就是我的想法
- 创建 "automator" 服务
- 为其设置快捷方式
- 从应用调用快捷方式
我能够创建 "automator" 服务,并且在 "automator" 中测试时它工作正常(通过 "Get Text" 操作)
但是,当我从应用程序触发快捷方式时,"Sublime Text" 不会打开带有所选文本的新选项卡(并且什么都不做)
这就是我设置 "automator" 服务的方式
- 服务在任何应用程序中接收选定的文本
- 复制到剪贴板
运行 这个 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
感谢您的帮助,谢谢
以下示例 AppleScript 代码 对我有用:
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
请注意,delay
命令 的 值 可能需要也可能不需要根据您系统的时间进行调整.
想要将文本从任何应用程序发送到 "Sublime Text 3",这就是我的想法
- 创建 "automator" 服务
- 为其设置快捷方式
- 从应用调用快捷方式
我能够创建 "automator" 服务,并且在 "automator" 中测试时它工作正常(通过 "Get Text" 操作)
但是,当我从应用程序触发快捷方式时,"Sublime Text" 不会打开带有所选文本的新选项卡(并且什么都不做)
这就是我设置 "automator" 服务的方式
- 服务在任何应用程序中接收选定的文本
- 复制到剪贴板
运行 这个 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
感谢您的帮助,谢谢
以下示例 AppleScript 代码 对我有用:
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
请注意,delay
命令 的 值 可能需要也可能不需要根据您系统的时间进行调整.