BitByteBit Posted November 9, 2009 Share Posted November 9, 2009 (edited) I wrote a little app to access my FTP, I made a function to delete and upload files. I'm using http://www.autoitscript.com/forum/index.php?showtopic=94212 this UDF. After I delete a file, it is told to run a function which gets all the file names and displays them in a list. However the deleted file doesn't disappear/the uploaded file isn't shown. The files do get deleted/put on the server, so the issue isn't there. If I restart the program the files are shown. Here is the code: expandcollapse popup#include <FTP.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> Opt("TrayIconDebug", 1) ProcessSetPriority(@AutoItPID,3) HotKeySet("!z", "OpenCMD") HotKeySet("!{Esc}", "Exit1") HotKeySet("!{F4}", "Exit2") $FU = "INTERNET_FLAG_TRANSFER_BINARY" $Flag = "INTERNET_FLAG_RELOAD" Global $FileName[1] Global $FileName1[1] $Connected = False $Clicked = 0 $DummyCheck = "" #Region Login/Open Local $hFtp, $hSession, $hFile, $tBuffer, $nSize, $nBytes Const $Host = '' const $Login = 'anonymous' const $Password = 'anonymous@anonymous.co.uk' #EndRegion Login/Open #Region ### START Koda GUI section ### Form= $FTP = GUICreate("File Server", 335, 242, 192, 124, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) GUISetBkColor(0x99B4D1) $Status = GUICtrlCreateLabel("Not Connected", 68, 5, 125, 15, $SS_CENTER) $Connect = GUICtrlCreateButton("Connect", 248, 20, 75, 33, $WS_GROUP) $Disconnect = GUICtrlCreateButton("Disconnect", 248, 100, 75, 33, $WS_GROUP) $List1 = GUICtrlCreateList("", 8, 20, 233, 149) $Put = GUICtrlCreateInput("", 8, 185, 225, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_ACCEPTFILES) $Upload = GUICtrlCreateButton("Upload", 246, 183, 78, 25, $WS_GROUP) $Back = GUICtrlCreateButton("Back", 248, 58, 75, 33, $WS_GROUP) $CMD = GUICtrlCreateButton("CMD", 247, 137, 75, 33, $WS_GROUP) $Active = GUICtrlCreateLabel("Current Directory:", 8, 220, 86, 17) $ActiveDir = GUICtrlCreateLabel("Not connected", 96, 220, 240, 17) GUISetState(@SW_SHOW) ;Delete Menu GUICtrlCreateContextMenu($List1) $delete = GUICtrlCreateMenuItem("&Delete", $List1) GUICtrlSetOnEvent(-1, "Delete") #EndRegion ### END Koda GUI section ### ; ; While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Disconnect() Exit Case $CMD OpenCMD() Case $Back Back() Case $Connect Connect() Case $Disconnect Disconnect() Case $List1 $Check = GUICtrlRead($List1) $FileName = StringSplit($Check, '.', 1) If Not @error Then $Clicked = $Clicked + 1 If $Clicked > 1 And $Check = $DummyCheck Then DownloadFile() $Clicked = 0 Else $DummyCheck = $Check ;$Clicked = $Clicked + 1 EndIf Else CD() $Path = _FTP_GetCurrentDir($hSession) GUICtrlSetData($ActiveDir, $Path) $Clicked = 0 EndIf Case $Upload $Read = GUICtrlRead($Put) If $Read <> "" Then $FileName = StringSplit($Read, '\', 1) $FileName1 = UBound($FileName) - 1 $Array1 = $FileName[$FileName1] Upload() Else MsgBox(0, "!", "Please drag a file into the Input Box") EndIf Case $delete Delete() EndSwitch WEnd Func Delete() $Check = GUICtrlRead($List1) $Path = _FTP_GetCurrentDir($hSession) $File123 = $Path & "/" & $Check $Ques = MsgBox(4, "?", "Do you want to delete: " & $Path & "/" & $Check) If $Ques = 6 Then _FTP_DeleteFile($hSession, $Check) If Not @error Then ToolTip($Path & $Check &" has been deleted") Sleep(1000) ToolTip("") GUICtrlSetData($List1, "") GetFileList() $Clicked = 0 Else ToolTip("Unable to delete: " & $Path) Sleep(950) ToolTip("") EndIf EndIf If $Ques = 7 Then Sleep(10) $Clicked = 0 EndIf EndFunc ;==>Delete Func Back() $Path = _FTP_GetCurrentDir($hSession) ;If not $Path <> "/" Then MsgBox(0,"!","You are in the root") ;MsgBox(0,"",$Path) $FileName = StringSplit($Path, '/', 2) $FileName1 = UBound($FileName, 1) - 1 $FileName1 = $FileName1 - 1 $Array1 = $FileName[$FileName1] _FTP_SetCurrentDir($hSession, '/' & $Array1) GUICtrlSetData($List1, "") GetFileList() $Path = _FTP_GetCurrentDir($hSession) GUICtrlSetData($ActiveDir, $Path) EndFunc ;==>Back Func CD() $Path = _FTP_GetCurrentDir($hSession) _FTP_SetCurrentDir($hSession, $Path & '/' & $Check) GUICtrlSetData($List1, "") Sleep(250) GetFileList() EndFunc ;==>CD Func Connect() _FTP_Startup() $hFtp = _FTP_Open('MyFtp') $hSession = _FTP_Connect($hFtp, $Host, $Login, $Password) If Not @error Then GUICtrlSetData($Status, "Connected") ToolTip("Connected as 'Anonymous'") Sleep(850) ToolTip("") EndIf _FTP_SetCurrentDir($hSession, '/aftp') If Not @error Then GetFileList() GUICtrlSetData($Status, "Connected as Anonymous") $Path = _FTP_GetCurrentDir($hSession) GUICtrlSetData($ActiveDir, $Path) EndIf $Connected = True EndFunc ;==>Connect ;I think the problem is here, or how it is being called, I say that because the same function works in a lighter version of the program I made. Any ideas? Func GetFileList() $tFind = DllStructCreate($tagWIN32_FIND_DATA) $hFind = _FTP_FileFindFirst($hSession, '', $tFind) _FTP_FileFindNext($hFind, $tFind) _FTP_FileFindNext($hFind, $tFind) while not @error $Data = DllStructGetData($tFind, 'FileName'); & @CR GUICtrlSetData($List1,$Data) _FTP_FileFindNext($hFind, $tFind) wend _FTP_FileFindClose($hFind) EndFunc Func Upload() If $Status = "Not Connected" Then Connect() ToolTip("Connecting") EndIf GUICtrlSetData($Status, "Uploading: " & $Array1) ToolTip("Uploading :" & $Array1) _FTP_PutFile($hSession, $Read, $Array1, $FU) If Not @error Then GUICtrlSetData($Status, "Uploaded :" & $Array1) ;GUICtrlSetData($List1, $Array1) ToolTip("Uploaded :" & $Array1) Sleep(2500) ToolTip("") GUICtrlSetData($Status, "Connected") GetFileList() Else ToolTip("Unable to Upload file:" & $Array1) GUICtrlSetData($Status, "Unable to Upload file:" & $Array1) Sleep(1750) ToolTip("") EndIf EndFunc ;==>Upload Func DownloadFile() $Selection = GUICtrlRead($List1) GUICtrlSetData($Status, "Downloading. . .") _FTP_GetFile($hSession, $Selection, @DesktopDir & '\' & $Selection) If Not @error Then GUICtrlSetData($Status, "Download Successful") ToolTip("Downloaded: " & $Selection & @CRLF & @DesktopDir & '\' & $Selection) Sleep(2500) ToolTip("") GUICtrlSetData($Status, "Connected") ToolTip("Opening: " & $Selection & @CRLF & @DesktopDir & '\' & $Selection) ShellExecute(@DesktopDir & '\' & $Selection) ToolTip("") Else GUICtrlSetData($Status, "Download Unsuccessful") ToolTip("Unable to download file: " & $Selection) Sleep(1500) ToolTip("") GUICtrlSetData($Status, "Connected") EndIf EndFunc ;==>DownloadFile Func Disconnect() _FTP_Disconnect($hSession) _FTP_Close($hFtp) _FTP_Shutdown() GUICtrlSetData($Status, "Not Connected") GUICtrlSetData($List1, "") GUICtrlSetData($ActiveDir, "Not Connected") ;Exit] $Connected = False EndFunc ;==>Disconnect Func OpenCMD() If $Connected = False Then ShellExecute("cmd", "/t:0a /k ftp XXX.co.uk") EndIf Sleep(2000) Sleep(150) Send("Anonymous{enter}") Sleep(275) Send("cd /FTP{enter}") Sleep(275) Send("dir{enter}") Else $Path = _FTP_GetCurrentDir($hSession) ShellExecute("cmd", "/t:0a /k ftp XXX.co.uk") EndIf Sleep(200) ;Send("anonymous{enter}") Sleep(150) ;Send("Anonymous{enter}") Sleep(175) Send("cd " & $Path & "{enter}") Sleep(175) Send("dir{enter}") EndIf EndFunc ;==>OpenCMD Func Exit1() Disconnect() Exit EndFunc ;==>Exit1 Func Exit2() If WinActive("File Server") = 1 Then Disconnect() Exit EndIf EndFunc ;==>Exit2 Any ideas? Edited November 9, 2009 by BitByteBit Link to comment Share on other sites More sharing options...
computergroove Posted November 9, 2009 Share Posted November 9, 2009 Send the F5 key? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
Yashied Posted November 12, 2009 Share Posted November 12, 2009 $hFind = _FTP_FileFindFirst($hSession, '', $tFind, $INTERNET_FLAG_RELOAD) My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
BitByteBit Posted November 13, 2009 Author Share Posted November 13, 2009 Thanks! 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