Hollowyearz

FTPLoginGUI

Dec 19th, 2013
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GUIConstantsEx.au3>
  2. #include <WindowsConstants.au3>
  3. #include <MsgBoxConstants.au3>
  4. #include <FTPEx.au3>
  5. Local $HostName
  6. Local $UserName
  7. Local $PassWord
  8. Local $testConn
  9. $Form1 = GUICreate("FTP Login Credentials", 357, 162, 192, 124)
  10. $HostNameB = GUICtrlCreateInput($HostName, 40, 24, 161, 21)
  11. $UserNameB = GUICtrlCreateInput($UserName, 40, 56, 161, 21)
  12. $PassWordB = GUICtrlCreateInput($PassWord, 40, 88, 161, 21)
  13. $Save = GUICtrlCreateButton("Save", 232, 24, 73, 25)
  14. GUICtrlSetTip(-1, "Saves login Info to INI File")
  15. $Load = GUICtrlCreateButton("Load", 232, 56, 73, 25)
  16. GUICtrlSetTip(-1, "Loads Previously Saved login Info from INI File")
  17. $clear = GUICtrlCreateButton("Clear", 232, 88, 73, 25)
  18. GUICtrlSetTip(-1, "Deletes any Previously saved INI Files")
  19. $testConn = GUICtrlCreateButton("Test Connection", 132, 120, 90, 25)
  20. GUICtrlSetTip(-1, "Test your Login Credentials")
  21. GUISetState(@SW_SHOW)
  22.  
  23. While 1
  24.                 $nMsg = GUIGetMsg()
  25.                 Switch $nMsg
  26.                                 Case $GUI_EVENT_CLOSE
  27.                                                 Exit
  28.                                 Case $Load
  29.                                                 _iniLoad()
  30.                                 Case $Save
  31.                                                 _iniSave()
  32.                                 Case $clear
  33.                                                 _clearAll()
  34.                                 Case $testConn
  35.                                                 _testConn()
  36.                 EndSwitch
  37. WEnd
  38.  
  39. Func _clearAll()
  40.                 GUICtrlSetData($HostNameB, "")
  41.                 GUICtrlSetData($UserNameB, "")
  42.                 GUICtrlSetData($PassWordB, "")
  43.                 $iniFile = @ScriptDir & "\login.ini"
  44.                 If FileExists($iniFile) Then
  45.                                 FileDelete($iniFile)
  46.  
  47.  
  48.                                 MsgBox(4096, $iniFile, $iniFile & ":  Was Deleted", 2)
  49.                 Else
  50.                                 MsgBox(4096, $iniFile, $iniFile & ":  Does not Exist", 2)
  51.                 EndIf
  52. _iniLoad()
  53.  
  54. EndFunc   ;==>_clearAll
  55.  
  56. Func _iniLoad()
  57.                 $HostName = IniRead(@ScriptDir & "\login.ini", "login", "HostName", "Default Value")
  58.                 $UserName = IniRead(@ScriptDir & "\login.ini", "login", "UserName", "Default Value")
  59.                 $PassWord = IniRead(@ScriptDir & "\login.ini", "login", "PassWord", "Default Value")
  60.                 GUICtrlSetData($HostNameB, $HostName)
  61.                 GUICtrlSetData($UserNameB, $UserName)
  62.                 GUICtrlSetData($PassWordB, $PassWord)
  63. EndFunc   ;==>_iniLoad
  64.  
  65. Func _iniSave()
  66.                 $HostName = GUICtrlRead($HostNameB)
  67.                 $UserName = GUICtrlRead($UserNameB)
  68.                 $PassWord = GUICtrlRead($PassWordB)
  69.                 IniWrite(@ScriptDir & "\login.ini", "login", "HostName", $HostName)
  70.                 IniWrite(@ScriptDir & "\login.ini", "login", "UserName", $UserName)
  71.                 IniWrite(@ScriptDir & "\login.ini", "login", "PassWord", $PassWord)
  72. EndFunc   ;==>_iniSave
  73.  
  74. Func _testConn()
  75.  
  76.                 Local $hOpen = _FTP_Open('MyFTP Control')
  77.                 Local $hConn = _FTP_Connect($hOpen, $HostName, $UserName, $PassWord)
  78.                                 If $hConn = 0 Then
  79.                                 MsgBox(0, "FTP Connection", "Connection not possible", 1)
  80.                                 EndIf
  81.                 If $hConn > 0 Then
  82.                                 MsgBox(0, "FTP Connection", "FTP Connected Successfully", 1)
  83.                                 EndIf
  84.                 Local $Ftpc = _FTP_Close($hConn)
  85.                 Local $Ftpo = _FTP_Close($hOpen)
  86.  
  87.  
  88. EndFunc   ;==>_testConn
Advertisement
Add Comment
Please, Sign In to add comment