Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.20 KB | None | 0 0
  1. #RequireAdmin
  2. #include <ButtonConstants.au3>
  3. #include <ComboConstants.au3>
  4. #include <EditConstants.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <StaticConstants.au3>
  7. #include <WindowsConstants.au3>
  8. #include <FTPEx.au3>
  9. #include <SFTPEx.au3>
  10.  
  11. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  12. #AutoIt3Wrapper_Compression=4
  13. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  14.  
  15. #Region ### START Koda GUI section ###
  16. $GUI = GUICreate("FTP tool", 308, 242, 643, 265)
  17. GUICtrlCreateLabel("Host", 16, 16, 26, 17)
  18. GUICtrlCreateLabel("Port", 192, 16, 23, 17)
  19. GUICtrlCreateLabel("Username", 16, 56, 52, 17)
  20. GUICtrlCreateLabel("Password", 16, 88, 50, 17)
  21. GUICtrlCreateLabel("Status : ", 8, 152, 43, 17)
  22. $status = GUICtrlCreateLabel("Not connected", 52, 152, 221, 17)
  23. $host = GUICtrlCreateInput("104.225.219.223", 48, 12, 121, 21)
  24. $port = GUICtrlCreateCombo("22", 224, 12, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
  25. GUICtrlSetData(-1, "21|80")
  26. $username = GUICtrlCreateInput("frenkey", 79, 52, 121, 21)
  27. $password = GUICtrlCreateInput("frenkey_mmo", 79, 81, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
  28. $connectBtn = GUICtrlCreateButton("CONNECT", 56, 192, 75, 25)
  29. $disconnectBtn = GUICtrlCreateButton("DISCONNECT", 143, 192, 107, 25)
  30. GUISetState(@SW_SHOW)
  31. #EndRegion ### END Koda GUI section ###
  32.  
  33. If GUICtrlRead($status) = 'Not connected' Then GUICtrlSetState($disconnectBtn, $GUI_DISABLE) ; disable disconnect button
  34. GUICtrlSetData($port, '21') ; default port
  35.  
  36. Global $status, $host, $port, $username, $password
  37.  
  38. While 1
  39.     $nMsg = GUIGetMsg()
  40.     Switch $nMsg
  41.         Case $GUI_EVENT_CLOSE
  42.  
  43.             Exit
  44.         Case $connectBtn
  45.             _connectFTP()
  46.  
  47.     EndSwitch
  48. WEnd
  49.  
  50. ; connection to FTP server
  51. Func _connectFTP()
  52.  
  53.     Local $_host = "104.225.219.223";GUICtrlRead($host) ; host name
  54.     Local $_username = "frenkey" ;GUICtrlRead($username) ; username
  55.     Local $_password = "frenkey_mmo";GUICtrlRead($password) ; password
  56.     Local $_port = 22 ;GUICtrlRead($port) ; port
  57.     Local $hdir = "/home/frenkey/webapps/GW2-MODS/GW2Minion64/"
  58.     Local $FTPopen = _FTP_Open('FTP connection test') ; name of connection
  59.              ConsoleWrite("FTP Open Handler : " & $FTPopen & @CRLF)
  60.     Local $FTPConnect = _FTP_Connect($FTPopen, GUICtrlRead($_host), GUICtrlRead($_username), GUICtrlRead($_password), 1, GUICtrlRead($_port),3) ; connect
  61.              ConsoleWrite("FTP Connect Handler : " & $FTPConnect & @CRLF)
  62.  
  63.         ; try to connect to server
  64.         If Not @error Then ; if not error
  65.             _FTP_DirGetCurrent($FTPConnect)
  66.              If @error Then ConsoleWrite("FTP Current dir set : " & @error & @CRLF)
  67.  
  68.             _FTP_DirSetCurrent($FTPConnect, $hdir)
  69.              If @error Then ConsoleWrite("FTP set dir : " & @error & @CRLF)
  70.  
  71.             GUICtrlSetData($status, "Connected") ; set status to connected
  72.             GUICtrlSetState($connectBtn, $GUI_DISABLE) ; disable connect button
  73.         Else
  74.             MsgBox(48, 'FTP connection error', "Can't connect to server, error = " & @error) ; if there is connection error
  75.             MsgBox(48, 'Test variables', 'server name = ' & $_host & ', username = ' & $_username & ', password = ' & $_password & ', port = ' & $_port) ; debugg message
  76.         EndIf
  77.  
  78.  
  79. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement