Usage:
For example I am chatting, "Ohh you should see the funny picture of Tim last weekend. One second let me upload it." I want a link to my image fast. All I want to do is drag a file and get a URL to it quick.
This script does just that. Just drag and drop a file into the window (after setting up the settings for your FTP server) and you will get URL's for your files. You can have it launch the files so you can copy the links to the clipboard (only the last one will be saved).
Special thanks goes to olfen for his FTP functions.
Code:
;You can hardcode your settings in here so you don't have to type them all the time. FTPURL = ;FTP URL. FTPU = ;FTP User Name FTPP = ;FTP Password PORT = ;FTP Port remotelocation = ;Remote folder to drop files into. weburl=http:// ;URL of the folder these files will be accessable from. ;If you don't want a GUI to always change your info just remove this section. gui, add, text,,FTP URL gui, add, edit,w400 h20,%FTPURL% gui, add, text,,FTP User Name gui, add, edit,w400 h20,%FTPU% gui, add, text,,FTP Password gui, add, edit,w400 h20,%FTPP% gui, add, text,,Port gui, add, edit,w40 h20,%PORT% gui, add, text,,Remote folder to drop files into. gui, add, edit,w400 h20,%remotelocation% gui, add, text,,URL of the folder these files will be accessable from. gui, add, edit,w400 h20,%weburl% ;Create GUI gui, add, text,, Copy last to clipboard. gui, add, checkbox, vclipboardcheck Checked gui, add, text,, Open URL after upload. gui, add, checkbox, vrunafter Checked gui, add, text, y+20 w400, Drop files to upload here. gui, add, edit, readonly w400 h80 vstatus gui, show,,Simple Folder FTP return ;Process a file once you drop a file in. GuiDropFiles: gui, submit, nohide Loop, parse, A_GuiControlEvent, `n { ;get file name without path. SplitPath, A_LoopField, name ;Connect and upload file. FtpOpen(FTPURL, PORT, FTPU , FTPP) FtpSetCurrentDirectory(remotelocation) FtpPutFile(A_LoopField, name) FtpClose() ;update status to show file uploaded updatemsg(weburl name) ;Copy to Clipboard and Run Options if(runafter=1) run, %weburl%%name% if(clipboardcheck=1) clipboard=%weburl%%name% } Return GuiClose: GuiEscape: ExitApp updatemsg(msg) { gui, submit, nohide global status if (status <> " ") updatestatus = %msg%`n%Status% GuiControl, ,Status, %updatestatus% } ;------------------------------------FTP Functions begin.------------------------------------ ;FTP functions coded by olfen (http://www.autohotkey.com/forum/topic10393.html) /* http://msdn.microsoft.com/library/en-us/wininet/wininet/ftp_sessions.asp http://msdn.microsoft.com/library/en-us/wininet/wininet/internetopen.asp http://msdn.microsoft.com/library/en-us/wininet/wininet/internetconnect.asp */ FtpCreateDirectory(DirName) { global ic_hInternet r := DllCall("wininet\FtpCreateDirectoryA", "uint", ic_hInternet, "str", DirName) If (ErrorLevel != 0 or r = 0) return 0 else return 1 } FtpRemoveDirectory(DirName) { global ic_hInternet r := DllCall("wininet\FtpRemoveDirectoryA", "uint", ic_hInternet, "str", DirName) If (ErrorLevel != 0 or r = 0) return 0 else return 1 } FtpSetCurrentDirectory(DirName) { global ic_hInternet r := DllCall("wininet\FtpSetCurrentDirectoryA", "uint", ic_hInternet, "str", DirName) If (ErrorLevel != 0 or r = 0) return 0 else return 1 } FtpPutFile(LocalFile, NewRemoteFile="", Flags=0) { ;Flags: ;FTP_TRANSFER_TYPE_UNKNOWN = 0 (Defaults to FTP_TRANSFER_TYPE_BINARY) ;FTP_TRANSFER_TYPE_ASCII = 1 ;FTP_TRANSFER_TYPE_BINARY = 2 If NewRemoteFile= NewRemoteFile := LocalFile global ic_hInternet r := DllCall("wininet\FtpPutFileA" , "uint", ic_hInternet , "str", LocalFile , "str", NewRemoteFile , "uint", Flags , "uint", 0) ;dwContext If (ErrorLevel != 0 or r = 0) return 0 else return 1 } FtpGetFile(RemoteFile, NewFile="", Flags=0) { ;Flags: ;FTP_TRANSFER_TYPE_UNKNOWN = 0 (Defaults to FTP_TRANSFER_TYPE_BINARY) ;FTP_TRANSFER_TYPE_ASCII = 1 ;FTP_TRANSFER_TYPE_BINARY = 2 If NewFile= NewFile := RemoteFile global ic_hInternet r := DllCall("wininet\FtpGetFileA" , "uint", ic_hInternet , "str", RemoteFile , "str", NewFile , "int", 1 ;do not overwrite existing files , "uint", 0 ;dwFlagsAndAttributes , "uint", Flags , "uint", 0) ;dwContext If (ErrorLevel != 0 or r = 0) return 0 else return 1 } FtpGetFileSize(FileName, Flags=0) { ;Flags: ;FTP_TRANSFER_TYPE_UNKNOWN = 0 (Defaults to FTP_TRANSFER_TYPE_BINARY) ;FTP_TRANSFER_TYPE_ASCII = 1 ;FTP_TRANSFER_TYPE_BINARY = 2 global ic_hInternet fof_hInternet := DllCall("wininet\FtpOpenFileA" , "uint", ic_hInternet , "str", FileName , "uint", 0x80000000 ;dwAccess: GENERIC_READ , "uint", Flags , "uint", 0) ;dwContext If (ErrorLevel != 0 or fof_hInternet = 0) return -1 FileSize := DllCall("wininet\FtpGetFileSize", "uint", fof_hInternet, "uint", 0) DllCall("wininet\InternetCloseHandle", "UInt", fof_hInternet) return, FileSize } FtpDeleteFile(FileName) { global ic_hInternet r := DllCall("wininet\FtpDeleteFileA", "uint", ic_hInternet, "str", FileName) If (ErrorLevel != 0 or r = 0) return 0 else return 1 } FtpRenameFile(Existing, New) { global ic_hInternet r := DllCall("wininet\FtpRenameFileA", "uint", ic_hInternet, "str", Existing, "str", New) If (ErrorLevel != 0 or r = 0) return 0 else return 1 } FtpOpen(Server, Port=21, Username=0, Password=0 ,Proxy="", ProxyBypass="") { IfEqual, Username, 0, SetEnv, Username, anonymous IfEqual, Password, 0, SetEnv, Password, anonymous If (Proxy != "") AccessType=3 Else AccessType=1 ;#define INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration ;#define INTERNET_OPEN_TYPE_DIRECT 1 // direct to net ;#define INTERNET_OPEN_TYPE_PROXY 3 // via named proxy ;#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS global ic_hInternet, io_hInternet, hModule hModule := DllCall("LoadLibrary", "str", "wininet.dll") io_hInternet := DllCall("wininet\InternetOpenA" , "str", A_ScriptName ;lpszAgent , "UInt", AccessType , "str", Proxy , "str", ProxyBypass , "UInt", 0) ;dwFlags If (ErrorLevel != 0 or io_hInternet = 0) { FtpClose() return 0 } ic_hInternet := DllCall("wininet\InternetConnectA" , "uint", io_hInternet , "str", Server , "uint", Port , "str", Username , "str", Password , "uint" , 1 ;dwService (INTERNET_SERVICE_FTP = 1) , "uint", 0 ;dwFlags , "uint", 0) ;dwContext If (ErrorLevel != 0 or ic_hInternet = 0) return 0 else return 1 } FtpClose() { global ic_hInternet, io_hInternet, hModule DllCall("wininet\InternetCloseHandle", "UInt", ic_hInternet) DllCall("wininet\InternetCloseHandle", "UInt", io_hInternet) DllCall("FreeLibrary", "UInt", hModule) }