如何使用automator发送新推文?

时间:2012-11-12 03:23:37

标签: macos twitter applescript automator

与此帖有关,https://apple.stackexchange.com/questions/70585/applescript-opens-new-window-for-everything-when-run

我想知道我是否可以突出显示所选文本并运行此服务,我可以在新推文文本框中显示所选文本吗?

这是当前的代码:

    activate application "Tweetbot"
tell application "System Events"
  tell process "Tweetbot"
      repeat until exists
          delay 0.4
      end repeat
      set frontmost to true
      delay 0.2
      keystroke "n" using command down
  end tell
end tell

http://i.stack.imgur.com/aahdK.png

http://i.stack.imgur.com/pHtkX.png

1 个答案:

答案 0 :(得分:1)

您可以将所选文本作为变量传递给Automator,并使用UI脚本来设置文本字段的内容。

on run {input, parameters}
    activate application "Tweetbot"
    tell application "System Events" to tell process "Tweetbot"
        keystroke "n" using command down
        set value of text area 1 of scroll area 1 of window 1 to (input as text)
    end tell
end run

如果使用包含除命令之外的其他修饰键的快捷方式运行脚本,请尝试将keystroke "n" using command down替换为click menu item "New Tweet" of menu 1 of menu bar item "Tweet" of menu bar 1