Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #include <MsgBoxConstants.au3>
- #include <FTPEx.au3>
- Local $HostName
- Local $UserName
- Local $PassWord
- Local $testConn
- $Form1 = GUICreate("FTP Login Credentials", 357, 162, 192, 124)
- $HostNameB = GUICtrlCreateInput($HostName, 40, 24, 161, 21)
- $UserNameB = GUICtrlCreateInput($UserName, 40, 56, 161, 21)
- $PassWordB = GUICtrlCreateInput($PassWord, 40, 88, 161, 21)
- $Save = GUICtrlCreateButton("Save", 232, 24, 73, 25)
- GUICtrlSetTip(-1, "Saves login Info to INI File")
- $Load = GUICtrlCreateButton("Load", 232, 56, 73, 25)
- GUICtrlSetTip(-1, "Loads Previously Saved login Info from INI File")
- $clear = GUICtrlCreateButton("Clear", 232, 88, 73, 25)
- GUICtrlSetTip(-1, "Deletes any Previously saved INI Files")
- $testConn = GUICtrlCreateButton("Test Connection", 132, 120, 90, 25)
- GUICtrlSetTip(-1, "Test your Login Credentials")
- GUISetState(@SW_SHOW)
- While 1
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $GUI_EVENT_CLOSE
- Exit
- Case $Load
- _iniLoad()
- Case $Save
- _iniSave()
- Case $clear
- _clearAll()
- Case $testConn
- _testConn()
- EndSwitch
- WEnd
- Func _clearAll()
- GUICtrlSetData($HostNameB, "")
- GUICtrlSetData($UserNameB, "")
- GUICtrlSetData($PassWordB, "")
- $iniFile = @ScriptDir & "\login.ini"
- If FileExists($iniFile) Then
- FileDelete($iniFile)
- MsgBox(4096, $iniFile, $iniFile & ": Was Deleted", 2)
- Else
- MsgBox(4096, $iniFile, $iniFile & ": Does not Exist", 2)
- EndIf
- _iniLoad()
- EndFunc ;==>_clearAll
- Func _iniLoad()
- $HostName = IniRead(@ScriptDir & "\login.ini", "login", "HostName", "Default Value")
- $UserName = IniRead(@ScriptDir & "\login.ini", "login", "UserName", "Default Value")
- $PassWord = IniRead(@ScriptDir & "\login.ini", "login", "PassWord", "Default Value")
- GUICtrlSetData($HostNameB, $HostName)
- GUICtrlSetData($UserNameB, $UserName)
- GUICtrlSetData($PassWordB, $PassWord)
- EndFunc ;==>_iniLoad
- Func _iniSave()
- $HostName = GUICtrlRead($HostNameB)
- $UserName = GUICtrlRead($UserNameB)
- $PassWord = GUICtrlRead($PassWordB)
- IniWrite(@ScriptDir & "\login.ini", "login", "HostName", $HostName)
- IniWrite(@ScriptDir & "\login.ini", "login", "UserName", $UserName)
- IniWrite(@ScriptDir & "\login.ini", "login", "PassWord", $PassWord)
- EndFunc ;==>_iniSave
- Func _testConn()
- Local $hOpen = _FTP_Open('MyFTP Control')
- Local $hConn = _FTP_Connect($hOpen, $HostName, $UserName, $PassWord)
- If $hConn = 0 Then
- MsgBox(0, "FTP Connection", "Connection not possible", 1)
- EndIf
- If $hConn > 0 Then
- MsgBox(0, "FTP Connection", "FTP Connected Successfully", 1)
- EndIf
- Local $Ftpc = _FTP_Close($hConn)
- Local $Ftpo = _FTP_Close($hOpen)
- EndFunc ;==>_testConn
Advertisement
Add Comment
Please, Sign In to add comment