pintas Posted May 16, 2010 Share Posted May 16, 2010 Hello everyone. I'm trying to make a little send to FTP script that when i right click on a file it allows me to send the file to my website by ftp, but i'm completely lost and i have no idea how to call the file path to use with the _FTP_FilePut command line from the shell context menu. Can anyone please point me in the right direction? I've actually sent a PM to gspino who has done exactly what i want, but i can't seem to get a response from him... Link to comment Share on other sites More sharing options...
GEOSoft Posted May 16, 2010 Share Posted May 16, 2010 (edited) This might do what you need. $sFilePath = FileOpenDialog ( "title", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "All Files (*.*)") If NOT @Error Then $sFileName = StringRegExpReplace($sFilePath, ".+\\(.*\..*)$", "/$1") _FTP_FilePut($l_FTPSession, $sFilePath, $s_RemotePath & $sFileName) EndIf I should add that in order to use this with the context menu you don't need the FileOpenDialog(). Just compile the script and add a shell handler in the registry at HKEY_CLASSES_ROOT\file Where you will send the file path to the compiled script as a parameter and use $CmdLine to get the file path that was passed to the script If $CmdLine[0] > 0 Then $sFilePath = $CmdLine[1] $sFileName = StringRegExpReplace($sFilePath, ".+\\(.*\..*)$", "/$1") _FTP_FilePut($l_FTPSession, $sFilePath, $s_RemotePath & $sFileName) EndIf Edited May 16, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
l3ill Posted May 16, 2010 Share Posted May 16, 2010 (edited) And to add stuff to the windows context menu look hereNeat idea...playing around with it now myself Edited May 16, 2010 by billo My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
l3ill Posted May 16, 2010 Share Posted May 16, 2010 Sweeet! it works! thanks George! My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
pintas Posted May 16, 2010 Author Share Posted May 16, 2010 (edited) I thank you both for your replies. Billo, did you change the registry in HKEY_CLASSES_ROOT\*... etc and pointed the command to your compiled script? If so, was the script like this? : If $CmdLine[0] > 0 Then $sFilePath = $CmdLine[1] $sFileName = StringRegExpReplace($sFilePath, ".+\\(.*\..*)$", "/$1") _FTP_FilePut($l_FTPSession, $sFilePath, $s_RemotePath & $sFileName) EndIf Do I need to declare Global $sFilePath, etc? Would you mind sharing it? I'm having some (obvious newbie) difficulties... No need for the real ftp details. Edited May 16, 2010 by pintas Link to comment Share on other sites More sharing options...
l3ill Posted May 16, 2010 Share Posted May 16, 2010 Sure thing here is the code I used CCP from various sources: #include <FTPEx.au3> Global $l_FTPSession, $sFilePath, $s_RemotePath, $Open $server = '[url="http://www.website.com"]www.website.com[/url]' $username = '******' $pass = '******' $Open = _FTP_Open('MyFTP') $l_FTPSession = _FTP_Connect($Open, $server, $username, $pass) ;$sFilePath = FileOpenDialog ( "title", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "All Files (*.*)") If $CmdLine[0] > 0 Then $sFilePath = $CmdLine[1] $sFileName = StringRegExpReplace($sFilePath, ".+\\(.*\..*){:content:}quot;, "/$1") _FTP_FilePut($l_FTPSession, $sFilePath, $s_RemotePath & $sFileName) _FTP_ProgressUpload($l_FTPSession, $sFileName, $s_RemotePath [$Percentage = ) EndIf Compile it in and point to this *.exe with the command section of the youtube tutorial from my other post (very well done tut BTW). I am still working on the progress bar and close function...but this still works w/out it. Good Luck! My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
GEOSoft Posted May 16, 2010 Share Posted May 16, 2010 I thank you both for your replies. Billo, did you change the registry in HKEY_CLASSES_ROOT\*... etc and pointed the command to your compiled script? If so, was the script like this? : If $CmdLine[0] > 0 Then $sFilePath = $CmdLine[1] $sFileName = StringRegExpReplace($sFilePath, ".+\\(.*\..*)$", "/$1") _FTP_FilePut($l_FTPSession, $sFilePath, $s_RemotePath & $sFileName) EndIf Do I need to declare Global $sFilePath, etc? Would you mind sharing it? I'm having some (obvious newbie) difficulties... No need for the real ftp details. Tip: Using HKEY_CLASSES_ROOT\* will probably mess things up horribly, use HKEY_CLASSES_ROOT\file instead. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
pintas Posted May 16, 2010 Author Share Posted May 16, 2010 Progress bar and close connection would be the s**t. I'm going to experiment on that. I'm also working on a little app to check the ftp for new files. This way i can send and receive files to/from my colleagues at work and I'll know when i have a new file. This is good if the computer is offline, i send the file to ftp and the other app will connect to the ftp site and warn the user if there's a new file and download it. Nice idea, huh? Link to comment Share on other sites More sharing options...
GEOSoft Posted May 16, 2010 Share Posted May 16, 2010 Sure thing here is the code I used CCP from various sources: #include <FTPEx.au3> Global $l_FTPSession, $sFilePath, $s_RemotePath, $Open $server = '[url="http://www.website.com"]www.website.com[/url]' $username = '******' $pass = '******' $Open = _FTP_Open('MyFTP') $l_FTPSession = _FTP_Connect($Open, $server, $username, $pass) ;$sFilePath = FileOpenDialog ( "title", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "All Files (*.*)") If $CmdLine[0] > 0 Then $sFilePath = $CmdLine[1] $sFileName = StringRegExpReplace($sFilePath, ".+\\(.*\..*){:content:}quot;, "/$1") _FTP_FilePut($l_FTPSession, $sFilePath, $s_RemotePath & $sFileName) _FTP_ProgressUpload($l_FTPSession, $sFileName, $s_RemotePath [$Percentage = ) EndIf Compile it in and point to this *.exe with the command section of the youtube tutorial from my other post (very well done tut BTW). I am still working on the progress bar and close function...but this still works w/out it. Good Luck! I'm not sure what the forum did to your code but that SRER was severly messed up in the process $sFileName = StringRegExpReplace($sFilePath, ".+\\(.*\..*){:content:}quot;, "/$1") Should be $sFileName = StringRegExpReplace($sFilePath, ".+\\(.*\..*)$", "/$1") George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
l3ill Posted May 16, 2010 Share Posted May 16, 2010 (edited) Yeah! what a mess! lol and if I go back and try to edit it I lose all my formatting. This should be correct now: #include <FTPEx.au3> Global $l_FTPSession, $sFilePath, $s_RemotePath, $Open $server = 'website' $username = '******' $pass = '******' $Open = _FTP_Open('MyFTP') $l_FTPSession = _FTP_Connect($Open, $server, $username, $pass) If $CmdLine[0] > 0 Then $sFilePath = $CmdLine[1] $sFileName = StringRegExpReplace($sFilePath, ".+\\(.*\..*)$", "/$1") _FTP_FilePut($l_FTPSession, $sFilePath, $s_RemotePath & $sFileName) _FTP_ProgressUpload($l_FTPSession, $sFileName, $s_RemotePath) EndIf Edited May 16, 2010 by billo My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
l3ill Posted May 16, 2010 Share Posted May 16, 2010 Well the close function was easy but the progress bar is proving to be more of a challenge than I had expected.I have been playing around with some stuff I found here but amazingly there is not much information on the subject.Perhaps some of the more experienced coders will steer us in the right direction. G'nite My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
pintas Posted May 16, 2010 Author Share Posted May 16, 2010 Nice find, but i'm also having some hard time with it... Link to comment Share on other sites More sharing options...
l3ill Posted May 17, 2010 Share Posted May 17, 2010 not fun anymore...what have you got so far? Here's mine: (yes I know it's cheating...couldn't get my GetFileSize to work. At least it's moving now expandcollapse popup#include <FTPEx.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ProgressConstants.au3> Global $l_FTPSession, $sFilePath, $s_RemotePath, $Open, $msg, $progressbar, $sFileName, $filesize, $s, $button, $wait $server = '' $username = '' $pass = '' $Open = _FTP_Open('MyFTP') $l_FTPSession = _FTP_Connect($Open, $server, $username, $pass) If @error Then MsgBox(0, "Connection", "Connect Error") Exit Else MsgBox(0, "Connection", "Connection Success", 1) EndIf If $CmdLine[0] > 0 Then $sFilePath = $CmdLine[1] $sFileName = StringRegExpReplace($sFilePath, ".+\\(.*\..*){:content:}quot;, "/$1") _FTP_FilePut($l_FTPSession, $sFilePath, $s_RemotePath & $sFileName) $FtpProgress = _FTP_ProgressUpload($l_FTPSession, $sFileName, $s_RemotePath) EndIf $filesize = FileGetSize($sFileName) GUICreate("FTP Upload", 220, 100, 100, 200) GUICtrlCreateLabel("Uploading: " & $sFileName, 2, 35) GUICtrlCreateLabel("File Size: " & $filesize, 2, 50) $progressbar = GUICtrlCreateProgress(10, 10, 200, 20) GUICtrlSetColor(-1, 32250); not working with Windows XP Style $button = GUICtrlCreateButton("Start", 75, 70, 70, 20) GUISetState() $wait = 300; wait 20ms for next progressstep $s = 0; progressbar-saveposition $msg = GUIGetMsg() For $i = 1 To 100 Step 5 GUICtrlSetData($progressbar, $i) Sleep($wait) Next $msg = $GUI_EVENT_CLOSE _FTP_Close($Open) My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
GEOSoft Posted May 17, 2010 Share Posted May 17, 2010 And just what is wrong with _FTP_ProgressUpload()? I admit the examples in the help file are pretty useless but the function is designed for what you want. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
pintas Posted May 18, 2010 Author Share Posted May 18, 2010 I think the problem is exactly that the help file for _FTP_ProgressUpload() is very imcomplete. I've tried just about anything, including a pretty func for percentage like shown on the help file, but i can't seem to get it to work. Link to comment Share on other sites More sharing options...
l3ill Posted May 18, 2010 Share Posted May 18, 2010 I suppose it's just too complicated for my level of experience. Without an example to chop up and play with...all the examples I could find were very complicated (some even scary)! Even as such I still spent a considerable amount of time trying different things, the above example was the only one I could even get to move.... My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
GEOSoft Posted May 18, 2010 Share Posted May 18, 2010 If I get the spare time at some point I'll try to work it out for you. It's just too hectic right now. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
l3ill Posted May 18, 2010 Share Posted May 18, 2010 Thanks Mr.Nice Guy ;-)... I haven't given up yet either, just getting over the fact that I'm not as clever as I thought I was. My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
pintas Posted May 22, 2010 Author Share Posted May 22, 2010 I've been tampering with FTP Uploader to see if i can duplicate it's effect, but i can't seem to get anywhere... Link to comment Share on other sites More sharing options...
l3ill Posted May 22, 2010 Share Posted May 22, 2010 (edited) This one is pretty cool too, a little easier to understand FTP GUI Client 1.0 by KaZoStill no "working" progress bar though...by working I mean the actual upload progress.Edit: you did get the one I posted above working though, didn't you?cyaBill Edited May 22, 2010 by billo My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example 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