Is it possible to change TC DIR from a D5 App? YES [solved]
Moderators: Hacker, petermad, Stefan2, white
Is it possible to change TC DIR from a D5 App? YES [solved]
Hi all,
The title says it all...
I wrote a small D5 program [TC_BUT_EXE.EXE] to find (and optionally run) programs that exist in any of the "Defaultxy.bar" s. ( It is published here since several months ago).
I found that sometimes I only need TC to have the EXE's dir in one of its panes. All I came up with until now is that my program puts the path in the clipboard, and I paste it into TC...
Is there a way to sent TC a message to change a pane to a specific folder ???
TIA,
The title says it all...
I wrote a small D5 program [TC_BUT_EXE.EXE] to find (and optionally run) programs that exist in any of the "Defaultxy.bar" s. ( It is published here since several months ago).
I found that sometimes I only need TC to have the EXE's dir in one of its panes. All I came up with until now is that my program puts the path in the clipboard, and I paste it into TC...
Is there a way to sent TC a message to change a pane to a specific folder ???
TIA,
Last edited by eitang on 2009-12-16, 11:00 UTC, edited 1 time in total.
AFAIK, there is no messages available with text parameters, only commands w/o params.
You may execute TOTALCMD.exe with parameters /O /S /L=<path> or send to TC's command line messages WM_SETTEXT with command cd <path> and WM_KEYDOWN with key VK_RETURN (this way will kill previous state of command line, so you need to backup it before).
You may execute TOTALCMD.exe with parameters /O /S /L=<path> or send to TC's command line messages WM_SETTEXT with command cd <path> and WM_KEYDOWN with key VK_RETURN (this way will kill previous state of command line, so you need to backup it before).
Wow, nice TC feature, I'd missed it! BTW, if user has some instances of TC launched, theese functions may send command to wrong window... Also, I think that MAX_PATH chars may be not enough to fit two paths, especially if them are long.Lefteous wrote:http://ghisler.ch/wiki/index.php/Addon_library
- franck8244
- Power Member
- Posts: 704
- Joined: 2003-03-06, 17:37 UTC
- Location: Geneva...
eitang, I will describe for you how it works:
1. define array of char and write to it following sequence of items:
> path to left dir
> (optional) #10 char and path to right dir
> (optional) #0 char and flags ('T', 'S' or 'ST')
e.g. you may write following chars to buffer: 'c', ':', '\', #10, 'd', ':', '\', #0, 'T' (9 chars total) - this will open C:\ and D:\ dirs in left and right panels in new tabs.
2. define struct COPYDATASTRUCT (perhaps in Delphi it will have name TCOPYDATASTRUCT) and set it fields to:
> dwData to ord('C') + 256 * ord('D')
> cbData to ammount of bytes used in defined buffer for all written information
> lpData to pointer to first char of buffer
3. use Windows function SendMessage with following parameters:
> handle of TC window
> WM_COPYDATA message
> 0
> pointer to defined TCOPYDATASTRUCT
1. define array of char and write to it following sequence of items:
> path to left dir
> (optional) #10 char and path to right dir
> (optional) #0 char and flags ('T', 'S' or 'ST')
e.g. you may write following chars to buffer: 'c', ':', '\', #10, 'd', ':', '\', #0, 'T' (9 chars total) - this will open C:\ and D:\ dirs in left and right panels in new tabs.
2. define struct COPYDATASTRUCT (perhaps in Delphi it will have name TCOPYDATASTRUCT) and set it fields to:
> dwData to ord('C') + 256 * ord('D')
> cbData to ammount of bytes used in defined buffer for all written information
> lpData to pointer to first char of buffer
3. use Windows function SendMessage with following parameters:
> handle of TC window
> WM_COPYDATA message
> 0
> pointer to defined TCOPYDATASTRUCT
OK, your help did help! A question
Mvv,
The program works perfectly now, but I had to guess some of the characters and part of the structure of the command line.
First of all Franck8244 helped me a lot by "translating" the C++ code into Delphi <g> [Many many thanks, Franck !] and then I had to guess some parameters that did not originally work...
Where can I find the official definition of this method of passing commands to TC from an external application?
I read (of course) the Help, but there you need to add command line delimiters (/) whereas in the PChar you do not. How did you know???
TIA,
The program works perfectly now, but I had to guess some of the characters and part of the structure of the command line.
First of all Franck8244 helped me a lot by "translating" the C++ code into Delphi <g> [Many many thanks, Franck !] and then I had to guess some parameters that did not originally work...
Where can I find the official definition of this method of passing commands to TC from an external application?
I read (of course) the Help, but there you need to add command line delimiters (/) whereas in the PChar you do not. How did you know???
TIA,
I don't know where to find but history.txt contains some info:
17.09.06 Added: Send WM_COPYDATA with dwData='E'+256*'M' and lpData pointing to em_xyz internal command (0-terminated) to execute that command. Accepts parameters separated by a space
12.04.06 Added: Support for environment variables in paths received via WM_COPYDATA from other programs
MVV,
>> ... history.txt ...
LOL.
Thank you very much.
This is not much of a documentation for such a capable openness of TC.
If our dear Christian did the job of adding these capacities to TC he had a reason, and probably wanted other programmers to be able to communicate with TC, so he must have documented it somewhere, I presume.
Maybe he will jump in here with some useful information.
I will scrutinize the history.txt , in the meanwhile <g>
Thanks a lot.
>> ... history.txt ...
LOL.
Thank you very much.
This is not much of a documentation for such a capable openness of TC.
If our dear Christian did the job of adding these capacities to TC he had a reason, and probably wanted other programmers to be able to communicate with TC, so he must have documented it somewhere, I presume.
Maybe he will jump in here with some useful information.
I will scrutinize the history.txt , in the meanwhile <g>
Thanks a lot.
A Little later:
I found a full description of the SEND and RECEIVE function around WM_CopyData:
http://delphi.about.com/od/windowsshellapi/a/wm_copydata.htm
... If you're interested.
Thanks.
I found a full description of the SEND and RECEIVE function around WM_CopyData:
http://delphi.about.com/od/windowsshellapi/a/wm_copydata.htm
... If you're interested.
Thanks.
I don't like Delphi (I hate VCL mainly; but I know how to operate with Windows API in it). I'm a C/C++ programmer, so my help on this API message first of all is here: http://msdn.microsoft.com/en-us/library/ms649011%28VS.85%29.aspx (of course, I have offline MSDN also and prefer it)eitang wrote:I found a full description of the SEND and RECEIVE function around WM_CopyData:
http://delphi.about.com/od/windowsshellapi/a/wm_copydata.htm
... If you're interested.

MVV,
>> I don't like Delphi (I hate VCL mainly
<LOL>
I used to (since 1981) program under CP/M and later MS DOS with compilable interpreters like dBase and Basic.
After awhile I "met" Turbo Pascal and really fell in love with this language. (50K the whole package !!!).
When "C" arrived, I did not give it any attention and, naturally, with Windows I switched to Delphi. So with D I stay <g>
>> I don't like Delphi (I hate VCL mainly
<LOL>
I used to (since 1981) program under CP/M and later MS DOS with compilable interpreters like dBase and Basic.
After awhile I "met" Turbo Pascal and really fell in love with this language. (50K the whole package !!!).
When "C" arrived, I did not give it any attention and, naturally, with Windows I switched to Delphi. So with D I stay <g>
Does anybody know how to pass path in Unicode using WM_COPYDATA function? I tried to use Unicode BOM and UTF-8 BOM, but it doesn't work for me. 
Also when I send message (I'm using "S" flag) and right panel is active, TC changes path but makes active left panel... Is there a way to avoid such behaviour?
OK, UTF-8 BOM with UTF-8 text works. But second question remains...

Also when I send message (I'm using "S" flag) and right panel is active, TC changes path but makes active left panel... Is there a way to avoid such behaviour?

OK, UTF-8 BOM with UTF-8 text works. But second question remains...