Is the TakeCommandIPC interface available from other console programs?

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
May 30, 2008
122
1
#1
I often use PowerShell to do specific tasks. However, I would still like the ability to communicate with the hosting TakeCommand instance in the same way that I can do with TCC. Is this possible? In theory, I can load TakeCommand.dll in Powershell, and I can do low-level things like send Windows messages, so it should be possible to get at all the pieces needed, but I'm not sure if or how I could combine them to work.

If anyone has any suggestions, or has done this themselves, I would be very interested.

Paul.
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#2
If PowerShell can call a DLL, you can use the TakeCommandIPC function in takecmd.dll. If not, there isn't any prepackaged way to do this, though the IPC is through a named pipe, so it wouldn't be too hard to add it.

The TakeCommandIPC function allows plugins to communicate with the controlling Take Command instance. The syntax is:

DLLExports int TakeCommandIPC( LPTSTR pszCommand, LPTSTR pszArguments );

The supported commands are:

HWND
Returns the Take Command window handle in pszArguments

TCTAB
Returns 1 if the process ID in pszArguments is running in a TC window

TCTABS
Returns the number of Take Command tab windows

HVIEW
Returns the handle of the active tab window in pszArguments

HELP
Displays the Take Command help for the topic in pszArguments

USAGE
Display the usage message in pszArguments in the status bar. The first line (up to the first CR) is displayed in the
status bar; the rest is displayed in the tooltip if you hover the mouse over the status bar.

STATUSBAR
Display the message in pszArguments in the status bar

TCTOOLBAR
Update the Take Command tab toolbar with pszArguments

TCFILTER
Return the selected filter in the list view in pszArguments

TCFILTER_CMD
Set the selected filter in the list view to the value in pszArguments

CDD
Change the folder and list view to the directory in pszArguments

TCFOLDER
Return the selected folder in the Folders tree control in pszArguments

SHORTCUT
Return the name of the shortcut that started Take Command in pszArguments

SELECTED
Return the currently selected text in pszArguments

SELECT
Mark the selection specified in pszArguments (top, left, bottom, right) in Take Command

START
Attach a hidden console window whose hex PID is in pszArguments

ACTIVATE
Activate the window whose handle is in pszArguments

WINDOW
Has a number of arguments (specified in pszArguments) to control the Take Command window:
MAX
MIN
HIDE
RES
TRAY
TRANS=n
FLASH=n
DETACH n (where n is the PID of the process to detach)
TOPMOST
NOTOPMOST
TOP
BOTTOM
 
May 30, 2008
122
1
#3
If PowerShell can call a DLL, you can use the TakeCommandIPC function in takecmd.dll. If not, there isn't any prepackaged way to do this, though the IPC is through a named pipe, so it wouldn't be too hard to add it.
Thanks. I didn't manage to get it to work on a quick try, but that's maybe because I haven't done much with calling DLLs direct from Powershell. I'll try from another program and see if I can get it working there - stick to one variable at a time :)

Paul
 
May 30, 2008
122
1
#4
Ah, I see the problem. TakeCommandIPC is name-mangled, so it's not accessible except from a suitable C++ program :(

I guess I could write a wrapper, or if you could publish the named pipe protocol I could use that. But otherwise, I'm stuck.
Paul.