microbious Posted June 13, 2009 Share Posted June 13, 2009 here is a code that i have for my simple FTP client program. To run the code u will need .FTP.au3 UDF expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <WindowsConstants.au3> ;FTP extra includes below #include <.FTP.au3> #include <Array.au3> FileInstall ('excelent.wav',@TempDir & '/excelent.wav') FileInstall ('begin.wav',@TempDir & '/begin.wav') FileInstall ('haha.wav',@TempDir & '/haha.wav') FileInstall ('outstand.wav',@TempDir & '/outstand.wav') $GUI = GUICreate("Connect",500,200) $inireadIP = IniRead ('settings.ini','MAIN','IP','');read IP from INI $inireadPORT = IniRead ('settings.ini','MAIN','PORT','');read PORT from INI $inireadUSER = IniRead ('settings.ini','MAIN','USERNAME','');reads username from ini $inireadPASS = IniRead ('settings.ini','MAIN','PASSWORD','');reads password from ini $IPwindow = _GUICtrlIpAddress_Create($GUI,25,0,125,20); create IP input box _GUICtrlIpAddress_Set($IPwindow,$inireadIP); set IP from iniread into IP input box GUICtrlCreateLabel ("IP=",0,3) $portinput = GUICtrlCreateInput ($inireadPORT,195,0,40,20); port input GUICtrlCreateLabel ("PORT=",150,3) guictrlsetlimit ($portinput,6,2); Port input limit $usernameinput = GUICtrlCreateInput ($inireadUSER,70,20,80,20);username input GUICtrlCreateLabel ("Username=",0,23) $passinput = GUICtrlCreateInput ($inireadPASS,70,40,80,20);password input GUICtrlCreateLabel ("Password=",0,43) $MessagesWindow = GUICtrlCreateEdit ('servermessages',240,0,260,60); log window $button = GUICtrlCreateButton ('Save',150,20,40,20);save IP $button2 = GUICtrlCreateButton ('Connect',150,40,60,20); connect SoundPlay (@TempDir & '/begin.wav') GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg case $button $IPvalue = _GUICtrlIpAddress_Get($IPwindow); get ip from IP input box and return result $PORTvalue = GUICtrlRead ($portinput) $USERNAMEvalue = GUICtrlRead ($usernameinput) $PASSvalue = GUICtrlRead ($passinput) $iniwriteIP = IniWrite ('settings.ini','MAIN','IP',$IPvalue) $iniwritePORT = IniWrite ('settings.ini','MAIN','PORT',$PORTvalue) $iniUSERNAME = IniWrite ('settings.ini','MAIN','USERNAME',$USERNAMEvalue) $iniPASSWORD = IniWrite ('settings.ini','MAIN','PASSWORD',$PASSvalue) SoundPlay (@TempDir & '/outstand.wav') Sleep (1000) MsgBox (0,'','Server '& $IPvalue & ':'& $PORTvalue & @CRLF &'Username: '& $USERNAMEvalue & @CRLF &'Password: '& $PASSvalue) case $button2 $IPvalue2 = _GUICtrlIpAddress_Get($IPwindow) $PORTvalue2 = GUICtrlRead ($portinput) $USERNAMEvalue = GUICtrlRead ($usernameinput) $PASSvalue = GUICtrlRead ($passinput) $FTPopen = _FTPOpen('nothing important here') $FTPconnect = _FTPConnect($FTPopen, $IPvalue2, $USERNAMEvalue, $PASSvalue) If $FTPconnect > 0 then SoundPlay (@TempDir & '/excelent.wav') Sleep (1000) MsgBox (0,'Information','You are now connected to '& $IPvalue2) Else SoundPlay (@TempDir & '/haha.wav') Sleep (1000) MsgBox (0,'ERROR',"Connection could not be made") EndIf $TCPconnect = TCPConnect ($IPvalue2,$PortValue2) $ServerMSG1 = TCPRecv ($TCPconnect,100) MsgBox (0,'Information',$ServerMSG1) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Notice $MessagesWindow = GUICtrlCreateEdit ('servermessages',240,0,260,60) ; log window ? I want this window to recive server messages that $ServerMSG1 = TCPRecv ($TCPconnect,100) gets upon connected. Problem is that $MessagesWindow had to be created before Case $button2. I cannot have $MessagesWindow = GUICtrlCreateEdit ($ServerMSG1,240,0,260,60); log window ? because i get error saying used before declaration. I also cannot create it after Case $Button2 Is there something i can do to work around it and have my GUICtrlCreateEdit ($ServerMSG1,240,0,260,60) to receive messages from $ServerMSG1 ? kinda like Log window. Thanks Link to comment Share on other sites More sharing options...
DCCD Posted June 13, 2009 Share Posted June 13, 2009 Please check this, see if there are any problems! expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <WindowsConstants.au3> ;FTP extra includes below #include "FTP.au3" #include <Array.au3> FileInstall('excelent.wav', @TempDir & '/excelent.wav') FileInstall('begin.wav', @TempDir & '/begin.wav') FileInstall('haha.wav', @TempDir & '/haha.wav') FileInstall('outstand.wav', @TempDir & '/outstand.wav') $GUI = GUICreate("Connect", 500, 200) $inireadIP = IniRead('settings.ini', 'MAIN', 'IP', '');read IP from INI $inireadPORT = IniRead('settings.ini', 'MAIN', 'PORT', '');read PORT from INI $inireadUSER = IniRead('settings.ini', 'MAIN', 'USERNAME', '');reads username from ini $inireadPASS = IniRead('settings.ini', 'MAIN', 'PASSWORD', '');reads password from ini $IPwindow = _GUICtrlIpAddress_Create($GUI, 25, 0, 125, 20); create IP input box _GUICtrlIpAddress_Set($IPwindow, $inireadIP); set IP from iniread into IP input box GUICtrlCreateLabel("IP=", 0, 3) $portinput = GUICtrlCreateInput($inireadPORT, 195, 0, 40, 20); port input GUICtrlCreateLabel("PORT=", 150, 3) GUICtrlSetLimit($portinput, 6, 2); Port input limit $usernameinput = GUICtrlCreateInput($inireadUSER, 70, 20, 80, 20);username input GUICtrlCreateLabel("Username=", 0, 23) $passinput = GUICtrlCreateInput($inireadPASS, 70, 40, 80, 20);password input GUICtrlCreateLabel("Password=", 0, 43) $MessagesWindow = GUICtrlCreateEdit('servermessages', 240, 0, 260, 60); log window $button = GUICtrlCreateButton('Save', 150, 20, 40, 20);save IP $button2 = GUICtrlCreateButton('Connect', 150, 40, 60, 20); connect SoundPlay(@TempDir & '/begin.wav') GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $button $IPvalue = _GUICtrlIpAddress_Get($IPwindow); get ip from IP input box and return result $PORTvalue = GUICtrlRead($portinput) $USERNAMEvalue = GUICtrlRead($usernameinput) $PASSvalue = GUICtrlRead($passinput) $iniwriteIP = IniWrite('settings.ini', 'MAIN', 'IP', $IPvalue) $iniwritePORT = IniWrite('settings.ini', 'MAIN', 'PORT', $PORTvalue) $iniUSERNAME = IniWrite('settings.ini', 'MAIN', 'USERNAME', $USERNAMEvalue) $iniPASSWORD = IniWrite('settings.ini', 'MAIN', 'PASSWORD', $PASSvalue) SoundPlay(@TempDir & '/outstand.wav') Sleep(1000) MsgBox(0, '', 'Server ' & $IPvalue & ':' & $PORTvalue & @CRLF & 'Username: ' & $USERNAMEvalue & @CRLF & 'Password: ' & $PASSvalue) Case $button2 $IPvalue2 = _GUICtrlIpAddress_Get($IPwindow) $PORTvalue2 = GUICtrlRead($portinput) $USERNAMEvalue = GUICtrlRead($usernameinput) $PASSvalue = GUICtrlRead($passinput) $FTPopen = _FTPOpen('nothing important here') $FTPconnect = _FTPConnect($FTPopen, $IPvalue2, $USERNAMEvalue, $PASSvalue) If $FTPconnect > 0 Then SoundPlay(@TempDir & '/excelent.wav') Sleep(1000) MsgBox(0, 'Information', 'You are now connected to ' & $IPvalue2) Else SoundPlay(@TempDir & '/haha.wav') Sleep(1000) MsgBox(0, 'ERROR', "Connection could not be made") EndIf $TCPconnect = TCPConnect($IPvalue2, $PORTvalue2) $ServerMSG1 = TCPRecv($TCPconnect, 100) If $ServerMSG1 <> "" Then GUICtrlSetData($MessagesWindow, _ $IPvalue2 & " > " & $ServerMSG1 & @CRLF & GUICtrlRead($MessagesWindow)) MsgBox(0, 'Information', $ServerMSG1) Case $GUI_EVENT_CLOSE Exit EndSwitch WEndoÝ÷ ÚZËØb±«¢+Ø$$%%ÀÌØíMÉÙÉ5MıÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸U% ÑɱMÑÑ ÀÌØí5ÍÍÍ]¥¹½Ü°|($$$$$ÀÌØí%AÙ±ÕȵÀìÅÕ½ÐìÐìÅÕ½ÐìµÀìÀÌØíMÉÙÉ5MĵÀì I1µÀìU% ÑɱI ÀÌØí5ÍÍÍ]¥¹½Ü¤¤ [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
Valuater Posted June 13, 2009 Share Posted June 13, 2009 Remember that SoundPlay() has a second parameter of... 1 = wait until sound has finished SoundPlay(@TempDir & '/haha.wav', 1) 8) Link to comment Share on other sites More sharing options...
microbious Posted June 13, 2009 Author Share Posted June 13, 2009 (edited) Thanks DCCD u doing me big favor LOL i just realised that i was doing it all wrong, instead of GUICtrlSetData i was trying GUICtrlSendData damn it it made more sense to me. Again thank u so much. I redesigned my code for Case button2 I did this because i wanted to make sure there is servers welcome message 1st. If no welcome message then HAHAHA try again or if ftp connected then say connected Was my first way better than this ? I mean i am not sure if every FTP server has welcoming message sent out (my FTP does it thats why i make this program in the first place, so i can give it to my game servers admins to access server files) Anyhow i included the source code with .FTP.au3 UDF file and all sounds so u guys can execute it without any errors if u want. Let me know what im doing wrong.Remote.rar Edited June 13, 2009 by lessstoopid Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now