FTP connect with command

English support forum

Moderators: white, Hacker, petermad, Stefan2

raytc
Senior Member
Senior Member
Posts: 274
Joined: 2004-06-28, 11:03 UTC

FTP connect with command

Post by *raytc »

May'be a strange question:

I've created a FTP connection to my local sat decoder (127.0.0.1).
I cannot connect directly to my decoder but haven to open first a little FPT server program.

However I often forget to open this program before to create a connection with TC.

Is there a possibility to integrate a command in TC Ftp to do both things together (so open ftpserver.exe and after that connect to 127.0.0.1)?
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

2raytc
Not natively, but with a script it is possible. Tell us if you are interested.
I switched to Linux, bye and thanks for all the fish!
raytc
Senior Member
Senior Member
Posts: 274
Joined: 2004-06-28, 11:03 UTC

Post by *raytc »

Well, if it is easy to do Ok, otherwise, no matter. :-)
TC 9.51 (x64) - win10
raytc
Senior Member
Senior Member
Posts: 274
Joined: 2004-06-28, 11:03 UTC

Post by *raytc »

Can you please tell me any ideas how to start create this script?
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

This is a simple example using AutoHotkey. I assume that the ftp connection will be started with Ctrl-F, so I overwrite the key combination to first ask for confirmation if some other program (in your case the ftp server) should be started, notepad in my example.

Code: Select all

; Ctrl-F in Total Commander
#IfWinActive ahk_class TTOTAL_CMD
$^f::
	MsgBox 4,, Notepad? ; Message box to ask if to start notepad
	IfMsgBox Yes
	{
		Run notepad.exe ; ADJUST THIS FOR YOUR FTP SERVER
		Sleep 2000 ; Wait 2 secs to give time for the process to start
	}
	WinActivate ahk_class TTOTAL_CMD ; Get the focus back to TC
	Send ^f ; Start the ftp dialog
	Return
I switched to Linux, bye and thanks for all the fish!
raytc
Senior Member
Senior Member
Posts: 274
Joined: 2004-06-28, 11:03 UTC

Post by *raytc »

Wow great, thank you!

If I disconnect my local ftp connection (127.0.0.1) will it be possible with the same script p.e. to close notepad.exe?

------------------

Would it be possible as well to use activate this script clicking on my toolbar button FTP connection (cm_FtpConnect)?
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

If I disconnect my local ftp connection (127.0.0.1) will it be possible with the same script p.e. to close notepad.exe?
I dont know your ftp server, but i assume it is possible. What i would do is overwrite the Ctrl-Shift-F in TC, disconnect, then activate the server window, shut down the server.
Would it be possible as well to use activate this script clicking on my toolbar button FTP connection (cm_FtpConnect)?
That is even easier, as you can start a script on the button, which does all you need.
I switched to Linux, bye and thanks for all the fish!
raytc
Senior Member
Senior Member
Posts: 274
Joined: 2004-06-28, 11:03 UTC

Post by *raytc »

Thank you SanskritFritz,
However I don't know this script language.

Can you please tell me how I have to change the script adapting it to clicking on the Ftp connect button in the toolbar and clicking on the disconnect button under the toolbar?

(connect/disconnect script only if ftp server = local /127.0.0.1)

Can you please tell me where to find a good script language manual/guide with the topfield classes mentioned?
raytc
Senior Member
Senior Member
Posts: 274
Joined: 2004-06-28, 11:03 UTC

Post by *raytc »

@sanskritfritz, Have you seen my message above?
TC 9.51 (x64) - win10
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

@sanskritfritz, Have you seen my message above?
Somehow it slipped my attention, sorry.
However I don't know this script language.
Now is the time to learn it :-)
Can you please tell me how I have to change the script adapting it to clicking on the Ftp connect button in the toolbar and clicking on the disconnect button under the toolbar?
You need a new button which starts a script like this:

Code: Select all

MsgBox 4,, Start local ftp server?
IfMsgBox Yes
{
	Run c:\Program Files\ftpserv\ftpserver.exe ; ADJUST THIS FOR YOUR FTP SERVER
	Sleep 2000 ; Wait 2 secs to give time for the process to start (adjust if necessary)
}
WinActivate ahk_class TTOTAL_CMD ; Get the focus back to TC
Send ^f ; Start the ftp dialog
Return
For the disconnect i will come up with something later i hope.
(connect/disconnect script only if ftp server = local /127.0.0.1)
That is pretty complicated, i dont know it now.
Can you please tell me where to find a good script language manual/guide with the topfield classes mentioned?
AutoHotkey has got an amazing help system. As mentioned above you cannot avoid to learn a little, if you want to use the scripts ;-)
I switched to Linux, bye and thanks for all the fish!
raytc
Senior Member
Senior Member
Posts: 274
Joined: 2004-06-28, 11:03 UTC

Post by *raytc »

Thank you very much.

I found a solution with your help.
Just create a new button and insert this code:

--------------------------------------------------------
Run E:\server\FTP server\tops.exe /s
WinActivate ahk_class TTOTAL_CMD
Send ^f
Return
--------------------------------------------------------

I haven't found:
- how to disable server when I click on disconnect button
- I have more FTP connections. My button with the script above has to connect automatic to one of these connections without ftp dialog. Don't know ho to do this. May'be I can fill in some parameter after the ^f command
raytc
Senior Member
Senior Member
Posts: 274
Joined: 2004-06-28, 11:03 UTC

Post by *raytc »

SanskritFritz wrote:AutoHotkey has got an amazing help system. As mentioned above you cannot avoid to learn a little, if you want to use the scripts ;-)
Do you know where I can find the TC "classes" for Autohotkey?
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

2raytc
Do you know where I can find the TC "classes" for Autohotkey?
Yes, the "AU3_Spy.exe" is included in the AutoHotkey distribution.
I switched to Linux, bye and thanks for all the fish!
raytc
Senior Member
Senior Member
Posts: 274
Joined: 2004-06-28, 11:03 UTC

Post by *raytc »

I would like to know what the ahk class is when I click on disconnect or another way to active a process clicking on a button.

Help is appreciated :-)

the ahk_class TCONNECT = the connect class
the ahk_class TDISCONNECT = doesn't exist
TC 9.51 (x64) - win10
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

the ahk_class TDISCONNECT = doesn't exist
True, the disconnect button is on the ftp toolbar, which is TPanel1 most of the time, depending on how many connections you have made. Catching the click on the button is rather cumbersome as it is no distinct button but only painted onto the toolbar. You can know the position of it and catch the mouse click accordingly. I personally dont prefer this solution, rather i would put another button onto the main toolbar (next to the ftp connect button), where i would start a script to disconnect and stop the server.
I switched to Linux, bye and thanks for all the fish!
Post Reply