FTP Login Script

Intermediate: dl dl dl

Hello all, recently I’ve been learning about FTP (File Transfer Protocol) and its uses. My friends and I are going to start up our own in fact. So to make their lives, mostly mine, a little easier, I made a little program to enable logging in exponentially easier. I did it with AutoHotkey and its¬†function, GUI. Without further ado here you are:

Open up something like notepad++, or any other text editor really. and copy paste the information below.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance force

; ----------------------------
Gui, New
Gui, Add, Text, , Username
Gui, Add, Edit, vUsername
Gui, Add, Text, , Password
Gui, Add, Edit, vPassword
Gui, Add, Text, , FTP Server
Gui, Add, Edit, vftp
Gui, Add, Button, gOK, Submit
Gui, Show, x800 y400 h200 w150
return





 
OK:
Gui, Submit
; -----------FTP Commands-----------
Run, %comspec% /k ftp %ftp%
WinActivate cmd.exe
sleep 300
Send, %Username%
Send, {Enter}
Send, %Password%
Send, {Enter}
; -----------Kill Program-----------
Process, Close, LogMeIn.exe
return

return
GuiClose:
ExitApp

Now, I know that a¬†massive block seems very intimidating and scary to a new programmer of AHK. Don’t fear, I was there too. I’ll explain a little in detail.

Gui, New
Gui, Add, Text, , Username
Gui, Add, Edit, vUsername
Gui, Add, Text, , Password
Gui, Add, Edit, vPassword
Gui, Add, Text, , FTP Server
Gui, Add, Edit, vftp
Gui, Add, Button, gOK, Submit
Gui, Show, x800 y400 h200 w150
return

The block of code above is just the GUI being drawn. For example, the line “Gui, Add, Text, , Username” generates a text box that says “Username”. With that basic example, hopefully you can figure out the rest, if you have trouble AutoHotkey has their own forums and System Reference Document.

Run, %comspec% /k ftp %ftp%
WinActivate cmd.exe
sleep 300
Send, %Username%
Send, {Enter}
Send, %Password%
Send, {Enter}

The above code is the actual executing of the command. It runs CMD with the command ftp and %ftp% which is the variable from the GUI drawing above. The Username and Password fields are for actually signing into the FTP server.

Process, Close, LogMeIn.exe
return

This code just makes sure that the code does not keep itself running. If you copy-pasted you should rename this in the code to YOURFILENAME.ahk or YOURFILENAME.exe.

Thank you all for your time. Follow the contact page if you have questions.

Leave a Reply

Your email address will not be published. Required fields are marked *

*