Pastebin functionality from Dropbox and AutoHotKey
I’ve had another idea… press a certain key combination, and you get a link to whatever text you had selected. This mirrors the ability to easily share text on sites such as pastebin. To use it, you’ll need AutoHotKey and a Dropbox account. Then grab my updated AHK Dropbox library.
Usage
Download the file to wherever you keep the autohotkey file you usually run. Somewhere at the top of your script, be sure to have the following line:
#Include dropbox.ahk
Somewhere else in your script, include the following:
;; copy the selected text to a file in my dropbox ^#c:: CopySelectionToDropbox() Return
Be sure to update your user id in the library file; I haven’t discovered a way to glean that information from the system, sadly. The only way to get it is to copy a public link of something in your dropbox and extract the number from that.
You’re welcome to use your own keyboard shortcut for it, of course; ctrl+windows+c is pretty awkward to press. I’m thinking the scroll lock key probably be a pretty decent place to assign it. For the full AHK key list, see this help document. The code for the new function is after the break.
How it works
CopySelectionToDropbox() { ;; put selection onto clipboard Copy() ;; get the location of the dropbox dropbox := GetDropboxFolderLocation() ;; write the text to file in public folder filename = %A_Now%.txt FileAppend %clipboard%, %dropbox%\Public\%filename% ;; get the public url of the last file copied user_id = 3771881 public_url := GetDropboxPublicURL(user_id, filename) ;; replace clipboard with url to text clipboard = %public_url% TrayTip Dropbox, Put selection in dropbox as %filename%`n`nLink put onto clipboard }
3 Comments