Control from external program?

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

HenrikHusted
Junior Member
Junior Member
Posts: 39
Joined: 2003-03-24, 10:47 UTC

Control from external program?

Post by *HenrikHusted »

Hi all,
Is it possible to control tcmd from an external program, ie. via windows message or dde?
I want to send a message from my program to tcmd so a specific file is selected. Is this possible?

Regards
Henrik
HenrikHusted
Junior Member
Junior Member
Posts: 39
Joined: 2003-03-24, 10:47 UTC

Found the solution

Post by *HenrikHusted »

Ups, I really should read the documentation better.
There's a command line option "/o" which does what I need.
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

And then there is AutoHotkey!
I switched to Linux, bye and thanks for all the fish!
HenrikHusted
Junior Member
Junior Member
Posts: 39
Joined: 2003-03-24, 10:47 UTC

Post by *HenrikHusted »

How does AutoHotkey let me select a specific file within tcmd?
The parameter "/o" only allows me to select the directory, the file itself is not selected.
Can AutoHotkey do this for me?
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

2HenrikHusted
Yes. Albeit not too reliable, as there would be no checking if the file exists (so a wrong file gets selected maybe), etc. but you can achieve positive results by simulating keystrokes in TC.
I think it would be much better if you desccribed the problem what you want to solve.
I switched to Linux, bye and thanks for all the fish!
HenrikHusted
Junior Member
Junior Member
Posts: 39
Joined: 2003-03-24, 10:47 UTC

Post by *HenrikHusted »

I want a standalone program to tell tcmd to select a specific file.

I.e. something like this:

::ShellExecute( NULL, "open", "c:\\Program Files\\totalcmd\\TOTALCMD.EXE", "/x c:\\mydir\\myfile.txt", NULL, SW_SHOWNORMAL );

and tcmd will go to "c:\mydir" and select "myfile.txt".

It doesn't have to be via ShellExecute, it could be messages, dde or whatnot.
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

I think that this can only be done correctly if you simulate things this way in AHK:

1. simulate + to open "expand selection" (class TCOMBOINPUT)
2. send file name to combobox
3. simulate enter

This will select the file but will not position cursor over it. Also you have to make sure that correct panel is active (which can be achieved via command line params to TC, no need to simulate here)
Last edited by majkinetor on 2006-01-11, 12:29 UTC, edited 3 times in total.
We are not doing this just for the money.
We are doing it for sh*t load of money.
 
 
r-moth.com
r-moth.deviantart.com
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

This is possible, but before someone would write that script, one question remains: why do you want to select a file? What is the purpose of selecting it? I'm asking because there are quite some experts here who might point you to a utility which just does what you want.
I switched to Linux, bye and thanks for all the fish!
HenrikHusted
Junior Member
Junior Member
Posts: 39
Joined: 2003-03-24, 10:47 UTC

Post by *HenrikHusted »

Could this be done from a plugin?
I read about the supported plugins but none of them seems to have this feature.

majkinetor suggestion seems like it could break with the next release of tcmd :-)
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

It will not break. It depends only on class name which usualy doesn't change in any program. If it is changed, however, you can just input new name.

I guess this can be done with Script plugin for TC. Be aware that it is still undocumented.

Also, above approach is very easy to implement. I didn't write any AHK script yet but from what I have seen around it is a peace of cake.
Last edited by majkinetor on 2006-01-11, 12:53 UTC, edited 1 time in total.
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

2HenrikHusted
btw, why don't you finally answer to Sans
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

HenrikHusted wrote:How does AutoHotkey let me select a specific file within tcmd?
The parameter "/o" only allows me to select the directory, the file itself is not selected.
Can AutoHotkey do this for me?
You can open the Quicksearch and then type the filename. After that you just have to press Ins (or space).

That all can be done by an autohotkey script.

cm_showquickSearch opens the quicksearchwindow, then send the specific filename and the cursor will be set to the file, ESC will close the quicksearch and 'space'will select the file while 'ins' will select the file and put the cursor to the next.

sheepdog

[edit]
But as SanskritFritz in between pointed out: You could not be sure that the right file is selected, e.g. if there is no file with this name in the directory.
[/edit]
"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
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

But what if the file does not exists? Then the wrong file will be selected. I think if you want to rely on the selection, you should be very careful with this approach. I dont really recommend it.
EDIT: oops, thanks Partner, exactly :-)
I switched to Linux, bye and thanks for all the fish!
User avatar
majkinetor
Senior Member
Senior Member
Posts: 369
Joined: 2005-11-20, 10:36 UTC
Location: Belgrade, Serbia
Contact:

Post by *majkinetor »

the one can check in script if file exists before continuing.

similar to batch command : if EXIST filename

You can use dogs approach but only if you are sure that file exists. In mine alternative you can leave that because dialog with "no matches found" will be isued by TC (I don't know if you can live with that)
We are not doing this just for the money.
We are doing it for sh*t load of money.
 
 
r-moth.com
r-moth.deviantart.com
HenrikHusted
Junior Member
Junior Member
Posts: 39
Joined: 2003-03-24, 10:47 UTC

Post by *HenrikHusted »

It looks like the best solution for me is to use the "/o" parameter to get to the correct directory and then cm_showquickSearch to find the file.

Thanks to all for the quick replies.
Post Reply