How to send commands to TC from other programs
Moderators: Hacker, petermad, Stefan2, white
How to send commands to TC from other programs
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)
Thank you very much.
AJC (#62576)
- pdavit
- Power Member
- Posts: 1529
- Joined: 2003-02-05, 21:41 UTC
- Location: Kavala -> Greece -> Europe -> Earth -> Solar System -> Milky Way -> Space
- Contact:
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
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!!!
Christian Ghisler Rules!!!
Re: How to send commands to TC from other programs
sanjkoc wrote: if I want ... swap the panels on TC
Maybe that helps as a workaround. Another way to pass comands to TC I do not know.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
sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
Delphi PM
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 ? ;)
Kind regards,
Claude
Clo

¤ 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 ? ;)

Claude
Clo
#31505 Traducteur Français de T•C French translator Aide en Français Tutoriels Français English Tutorials
- Munango-Keewati
- Junior Member
- Posts: 31
- Joined: 2003-02-19, 18:45 UTC
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
'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
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
).
I was thinking of a TC plugin with an external exe and that
function'd be useful.
Thanks again and ciao.
AJC (#62576)
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

I was thinking of a TC plugin with an external exe and that
function'd be useful.
Thanks again and ciao.
AJC (#62576)
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.
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.