Created
August 3, 2012 16:19
-
-
Save romainbriche/3249159 to your computer and use it in GitHub Desktop.
Copy title and URL of the current page in Safari to a new tweet in Tweetbot for Mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- TweetViaTweetbot.applescript | |
-- Copy title and URL in the front most window of Safari to Tweetbot with link | |
-- Author: Romain Briche | |
on copyTitleAndLinkToTweetbot(theTitle, theURL) | |
tell application "System Events" | |
set tweet to theTitle & " " & theURL & " via @" | |
set the clipboard to tweet as text | |
delay 0.2 -- to make sure the clipboard will be set correctly | |
keystroke "n" using {command down} | |
keystroke "v" using {command down} | |
delay 0.2 -- to make sure the clipboard will be set correctly | |
end tell | |
end copyTitleAndLinkToTweetbot | |
tell application "System Events" | |
if not (exists application process "Tweetbot") or not (exists application process "Safari") then | |
display alert "Tweetbot and Safari Required" message "You have to launch Tweetbot and Safari before executing script" | |
end if | |
end tell | |
tell first document of application "Safari" | |
set pageTitle to name | |
set pageURL to URL | |
end tell | |
tell application "Tweetbot" to activate | |
set theClipboard to the clipboard | |
copyTitleAndLinkToTweetbot(pageTitle, pageURL) | |
set the clipboard to theClipboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What's your license?
Can I share my forks Script?