How to send commands to TC from other programs

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
sanjkoc
Junior Member
Junior Member
Posts: 20
Joined: 2004-07-13, 15:48 UTC
Location: Italy

How to send commands to TC from other programs

Post by *sanjkoc »

How can I send commands to TC from other programs other than emulate keyboard and/or mouse? For example, if I want that the pressing of a button of my program to swap the panels on TC, can I send a cm_Exchange to TC? And, if yes, how? I mean at low level.

Thank you very much.
AJC (#62576)
User avatar
pdavit
Power Member
Power Member
Posts: 1529
Joined: 2003-02-05, 21:41 UTC
Location: Kavala -> Greece -> Europe -> Earth -> Solar System -> Milky Way -> Space
Contact:

Post by *pdavit »

Total Commander's internal commands are indeed internal!

I don't know if TCSriptEditor can be of help to you: http://www.ghisler.ch/board/viewtopic.php?t=2499
"My only reason for still using M$ Window$ as an OS is the existence of Total Commander!"
Christian Ghisler Rules!!!
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Re: How to send commands to TC from other programs

Post by *Sheepdog »

sanjkoc wrote: if I want ... swap the panels on TC
Total Commander Help Index: 4. Configuration and switches a. Command line parameters wrote:/O If Total Commander is already running, activate it and pass the path(s) in the command line to that instance (overrides the settings in the configuration dialog to have multiple windows)

Examples:

totalcmd.exe /O /L=c:\ /R="d:\doc" Activate already running Total Commander and set the left path to c:\, and the right path to d:\doc
Maybe that helps as a workaround. Another way to pass comands to TC I do not know.

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
User avatar
Clo
Moderator
Moderator
Posts: 5731
Joined: 2003-12-02, 19:01 UTC
Location: Bordeaux, France
Contact:

Delphi PM

Post by *Clo »

2sanjkoc
:) Hello !
¤ In the principle, you could use the Delphi "Post message" function. It sends commands which are pre-defined variables. I don't know whether it's possible in TC.
If the Author'ld pass around ? ;)

:mrgreen: Kind regards,
Claude
Clo
#31505 Traducteur Français de TC French translator Aide en Français Tutoriels Français English Tutorials
User avatar
Munango-Keewati
Junior Member
Junior Member
Posts: 31
Joined: 2003-02-19, 18:45 UTC

Post by *Munango-Keewati »

You can use VBS (Visual Basic Script) to send keystrokes. Here's a sample that looks up words from almost any application in MS Bookshelf:

'Bookshelf lookup, run from keyboard shortcut
Dim vPath, vDefine
vPath = "c:\Progra~1\Utilit~1\Books95\BS9532.EXE"
Set oHtml = CreateObject("htmlfile")
Set WshShell = WScript.CreateObject("WScript.Shell")
Wscript.Sleep 200
WshShell.SendKeys "^c" '"%e" & "c"
vDefine = Trim(oHtml.ParentWindow.ClipboardData.GetData("text"))
'WshShell.AppActivate "Bookshelf" 'doesn't work
WshShell.Run vPath, 9
Wscript.Sleep 400
WshShell.SendKeys "%b" & "d", True ' Select dictionary
WshShell.SendKeys vDefine, True
WshShell.SendKeys "{ENTER}", True
Wscript.Quit


Or you can create a VBA macro to use from within Office programs. Here's one that I use from within Word to capture the path of the current document and, if I like, open that path in TC:

Sub PathDisplay()
Dim vcopy, vTCPath As String
Dim Message, Title, Default, MyValue
MyValue = 0
vTCPath = "c:\Program Files\Utilities\wincmd\TOTALCMD.EXE" 'set TC path
'vTCPath = "c:\WINNT\explorer.exe"
Title = "Path and Filename of Current Document" ' Set title.
Message = "PATH:" & Chr(13) & _
ActiveDocument.Path & "\" & Chr(13) & Chr(13) & _
"FILENAME:" & Chr(13) & _
ActiveDocument.Name & Chr(13) & _
Chr(13) & Chr(13) & _
"To copy to clipboard, Enter" & Chr(13) & _
Chr(13) & _
"1 for PATH and FILENAME," & Chr(13) & _
"2 for FILENAME only," & Chr(13) & _
"3 for PATH only" & Chr(13) & _
Chr(13) & _
"4 to open Path folder in File Manager"
Default = 1 ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)

Select Case MyValue ' Evaluate Number.
Case 1
vcopy = ActiveDocument.FullName
Case 2
vcopy = ActiveDocument.Name
Case 3
vcopy = ActiveDocument.Path

Case 4
vcopy = ActiveDocument.Path & "\"
vcopy = """" & vcopy & """"
ReturnValue = Shell(vTCPath & " /R=" & vcopy, 1) ' Run TC
Exit Sub

Case Else ' Other values, inc Cancel
'MsgBox "Input Error: " & MyValue
Exit Sub
End Select

' if 1-3, then
Dim MyData As DataObject
Set MyData = New DataObject
MyData.SetText vcopy
MyData.PutInClipboard
Set MyData = Nothing
End Sub

There are Usenet groups about both VBA and VBS, and lots of other info available online.

--Munango-Keewati
sanjkoc
Junior Member
Junior Member
Posts: 20
Joined: 2004-07-13, 15:48 UTC
Location: Italy

Post by *sanjkoc »

Thanks to everybody, I'll think about all your kind advices.

I supect there is a stright way sending WM_Commands to the
TC window, but maybe only Mr Ghisler knows (and perhaps
TCSriptEditor's author :wink: ).

I was thinking of a TC plugin with an external exe and that
function'd be useful.

Thanks again and ciao.
AJC (#62576)
User avatar
Lefteous
Power Member
Power Member
Posts: 9537
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2sanjkoc
You'll find sample code in this thread:
http://www.ghisler.ch/board/viewtopic.php?t=511
sanjkoc
Junior Member
Junior Member
Posts: 20
Joined: 2004-07-13, 15:48 UTC
Location: Italy

Post by *sanjkoc »

Bingo!!
Thank you very much, now I've a lot to study and to try...

Ciao.
AJC (#62576)
User avatar
foscmgt
Junior Member
Junior Member
Posts: 25
Joined: 2003-02-20, 11:25 UTC
Location: Sabadell

Post by *foscmgt »

Another way is ussing Autoit ( http://www.hiddensoft.com )
Manel #20741
User avatar
Aezay
Senior Member
Senior Member
Posts: 269
Joined: 2003-02-12, 07:27 UTC
Location: Denmark
Contact:

Post by *Aezay »

I have made a program for sending commands to other windows (programs), its called hWnd Monitor.
You can get it here, but I wont recommand you to use it, as its very complicated and not very user friendly.
If you still want to try it out, on your own risk of course, the message tab is what I believe you are looking for.
sanjkoc
Junior Member
Junior Member
Posts: 20
Joined: 2004-07-13, 15:48 UTC
Location: Italy

Post by *sanjkoc »

Many thanks to foscmgt and Aezay, too.
More things to study! :mrgreen:

Ciao.
AJC (#62576)
Post Reply