I reworked @pathartl‘s screenie script so that it also uploads to yFrog. I’m just putting it here because I know I’ll lose it if i don’t.
set filename to do shell script "date '+date-%Y-%m-%d-time-%H-%M-%S'"
do shell script "screencapture -i ~/Dropbox/Public/Screenshots/" & filename & ".png"
set dropboxurl to "http://dl.dropbox.com/u/440480/Screenshots/" & filename & ".png"
set tinyURL to (do shell script "curl --stderr /dev/null "http://bit.ly/api?url=" & dropboxurl & """)
tell application "Finder" to set the clipboard to tinyURL
delay 7
-- start of script
set the action_URL to "http://yfrog.com/api/upload"
-- the above cgi sends back your form data arguments, good for testing!
set the form_data to "url=" & dropboxurl & "&username=joshbetz&password=PASSWORD&key= P6FOXGSZ53932d4fae0d57c8ce72e966c20a70d4"
set the query_results_file to (path to home folder as text) & "My Results
File"
try
with timeout of 20 seconds -- try connecting for 1 minute
tell application "URL Access Scripting"
download the action_URL to file the query_results_file form data form_data replacing yes with progress
quit
end tell
end timeout
tell application "Finder"
set the file type of the file query_results_file to "TEXT"
set the creator type of the file query_results_file to "MSIE"
-- open the file query_results_file
end tell
on error the error_message number error_number
tell application "URL Access Scripting" to quit
if the error_number is not -128 then
tell application (path to frontmost application as text)
beep
display dialog the error_message buttons {"Cancel"} default button 1
end tell
end if
end try
-- end of script
tell application "System Events"
tell XML element 1 of contents of XML file query_results_file
set tinyURL to (value of (XML elements whose name is "mediaurl")) as string
end tell
end tell
tell application "Finder" to set the clipboard to tinyURL
tell application "Finder" to delete query_results_file
Comments 1
Comments are closed.