Jump to content
Sign in to follow this  
pintas

Shell menu help

Recommended Posts

pintas

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...

Share this post


Link to post
Share on other sites
GEOSoft

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 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!"

Share this post


Link to post
Share on other sites
pintas

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. :idea:

Edited by pintas

Share this post


Link to post
Share on other sites
l3ill

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!

Share this post


Link to post
Share on other sites
GEOSoft

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. :idea:

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!"

Share this post


Link to post
Share on other sites
pintas

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?

Share this post


Link to post
Share on other sites
GEOSoft

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!"

Share this post


Link to post
Share on other sites
l3ill

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 by billo

Share this post


Link to post
Share on other sites
l3ill

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 :idea:

Share this post


Link to post
Share on other sites
pintas

Nice find, but i'm also having some hard time with it... :idea:

Share this post


Link to post
Share on other sites
l3ill

:) 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 :idea:

#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)

Share this post


Link to post
Share on other sites
GEOSoft

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!"

Share this post


Link to post
Share on other sites
pintas

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. :idea:

Share this post


Link to post
Share on other sites
l3ill

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....:idea:

Share this post


Link to post
Share on other sites
GEOSoft

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!"

Share this post


Link to post
Share on other sites
pintas

I've been tampering with FTP Uploader to see if i can duplicate it's effect, but i can't seem to get anywhere... :idea:

Share this post


Link to post
Share on other sites
l3ill

This one is pretty cool too, a little easier to understand FTP GUI Client 1.0 by KaZo

Still 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?

cya

Bill

Edited by billo

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.