Jump to content

Shell menu help


Recommended Posts

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

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

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
Link to comment
Share on other sites

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:

Link to comment
Share on other sites

:) 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)
Link to comment
Share on other sites

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

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:

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...