"simple folder ftp" coded as a Autohotkey (.ahk) file ( only 4kb ) published @ http://autohotkey.com/forum/topic45154.html
NOTE only the ahk version with hardcoded ftp data works on my pc,
maybee caused on the fact, that i use only the AutoHotkey.exe#_prog saved on the C:/ partition.
Editable
→requiers 2 files http://4rtist.com/autohotkey.exe#_300kb saved it where you want i.e. Desktop, program files +
http://4rtist.com/ftp.ahk#_4kb →click the file
→choose the downloaded autohotkey.exe →Tick "always open this kind of files with this prog"
You can /should modify in the editor the ftp.ahk file i.e. -_-gui size -_-save ftp data and hide the than not necessary fields
The code from the file ( which you can use instead of the http://4rtist.com/ftp.ahk file )
;CODE start ↓
;gui designed ICEfreez http://autohotkey.com/forum/topic45154.html
#singleinstance force
;You can hardcode your settings in here so you don't have to type them all the time.
FTPURL = ftp.domain ;FTP URL.
FTPU = ;FTP User Name
FTPP = ;FTP Password
PORT =21 ;FTP Port
remotelocation =
weburl =
;If you don't want a GUI to always change your info just remove this section.
gui, add, text,,FTP URL
gui, add, edit,w600 h40,%FTPURL%
gui, add, text,,FTP User Name
gui, add, edit,w600 h20,%FTPU%
gui, add, text,,FTP Password
gui, add, edit,w600 h20,%FTPP%
gui, add, text,,Port
gui, add, edit,w60 h20,%PORT%
gui, add, text,,Remote folder to drop files into.
gui, add, edit,w600 h20,%remotelocation%
gui, add, text,,URL of the folder these files will be accessable from.
gui, add, edit,w600 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 600, Drop files to upload here.
gui, add, edit, readonly w600 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://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("wininetFtpCreateDirectoryA", "uint", ic_hInternet, "str", DirName)
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}
FtpRemoveDirectory(DirName) {
global ic_hInternet
r := DllCall("wininetFtpRemoveDirectoryA", "uint", ic_hInternet, "str", DirName)
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}
FtpSetCurrentDirectory(DirName) {
global ic_hInternet
r := DllCall("wininetFtpSetCurrentDirectoryA", "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("wininetFtpPutFileA"
, "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("wininetFtpGetFileA"
, "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("wininetFtpOpenFileA"
, "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("wininetFtpGetFileSize", "uint", fof_hInternet, "uint", 0)
DllCall("wininetInternetCloseHandle", "UInt", fof_hInternet)
return, FileSize
}
FtpDeleteFile(FileName) {
global ic_hInternet
r := DllCall("wininetFtpDeleteFileA", "uint", ic_hInternet, "str", FileName)
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}
FtpRenameFile(Existing, New) {
global ic_hInternet
r := DllCall("wininetFtpRenameFileA", "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("wininetInternetOpenA"
, "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("wininetInternetConnectA"
, "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("wininetInternetCloseHandle", "UInt", ic_hInternet)
DllCall("wininetInternetCloseHandle", "UInt", io_hInternet)
DllCall("FreeLibrary", "UInt", hModule)
}
5 comments so far...