TC window title as parameter
Moderators: Hacker, petermad, Stefan2, white
TC window title as parameter
Hello,
I would like to have the title of the Total Commander window as a parameter for executing commands from the symbol bar.
Reason: I want to modify the TC window using an external script, but that needs the window title to know which window to address (using the VBScript commands 'Shell.appActivate nameStr' and 'Shell.sendkeys' of VBScript).
Thanks,
Jesco
I would like to have the title of the Total Commander window as a parameter for executing commands from the symbol bar.
Reason: I want to modify the TC window using an external script, but that needs the window title to know which window to address (using the VBScript commands 'Shell.appActivate nameStr' and 'Shell.sendkeys' of VBScript).
Thanks,
Jesco
2Jesco
Shell.appActivate doesn't requires the exact window title, so that you can call it with the first part of TC window title e.g.
If you are work with specific version you can use
You cannot use TC class name because it requires API calling which you cannot call in VB script
Shell.appActivate doesn't requires the exact window title, so that you can call it with the first part of TC window title e.g.
Code: Select all
Shell.appActivate "Total Commander " ' don't delete the last space
Code: Select all
Shell.appActivate "Total Commander 7.55a -"
@MVV: as ts4242 already pointed out, it is not possible to make use of window classes in VBScript that is somewhat limited in its functionality.
@ts4242: I know that it is possible to specify just part of the window title for the Shell.appActivate command, but that is not a solution: I want to modify the instance of TC from which I called the script. Currently I use 'Total Commander' as the window name string but the result is arbitrary when there is more than one instance open (as any of the open instances might be activated). Therefore I would like to pass the window name using a parameter.
Cheers,
Jesco
@ts4242: I know that it is possible to specify just part of the window title for the Shell.appActivate command, but that is not a solution: I want to modify the instance of TC from which I called the script. Currently I use 'Total Commander' as the window name string but the result is arbitrary when there is more than one instance open (as any of the open instances might be activated). Therefore I would like to pass the window name using a parameter.
Cheers,
Jesco
You can do this by saving ProcessID returned by the Shell command and use this value in AppActivate, here is an exampleJesco wrote:I want to modify the instance of TC from which I called the script.
Code: Select all
Dim lngProcessID
Dim cShell
Set cShell = WScript.CreateObject("WScript.Shell")
lngProcessID = cShell.Exec("%Commander_Path%\TOTALCMD.EXE").ProcessID
MsgBox "Activate another window then back and press OK to close Total Commander instance started by this script"
cShell.AppActivate lngProcessID
cShell.SendKeys "%{F4}"
Well, my script does (and shall) not start a new TC instance, so there is no possibility to return the process ID. I execute it from an already running instance.lngProcessID = cShell.Exec("%Commander_Path%\TOTALCMD.EXE").ProcessID
Btw, %Commander_Path% is just a placeholder and would have to be replaced by the full path as it is only defined within TC, am I right?
- Balderstrom
- Power Member
- Posts: 2148
- Joined: 2005-10-11, 10:10 UTC
No. Every application started from Total Commander inherits it's copy of the Environment. You can also start a command prompt modify variables, or add more then start a program -- and it will inherit the current CMD Prompt environment.
For example, this is my Launch_TC.cmd that I use from a flash drive for a portable TC -- when not at home.
You can also modify the Environment by changing a couple Registry Keys.
For example, this is my Launch_TC.cmd that I use from a flash drive for a portable TC -- when not at home.
Code: Select all
CALL:GET_PATH "%CD%"
ECHO LocalDrive: %LocalDrive%
SET APPDATA=%LocalDrive%\xAppData
SET MyDOCS=%LocalDrive%\Documents
SET ProgramFiles=%LocalDrive%\Programs
SET TCDIR=%ProgramFiles%\TotalCMD
SET TCMD=%TCDIR%\TotalCMD.exe
SET TCMC="%TCTOOLS%\TCMC.exe" 50
SET TCDAT=%TCDIR%\DATA
SET TCDATA=%TCDIR%\DATA
SET TCTOOLS=%TCDIR%\TOOLS
SET AHKDIR=%ProgramFiles%\AutoHotKey
SET AHKICO=%AHKDIR%\AutoHotKey_08.ico
SET AHK="%AHKDIR%\AutoHotKey.exe" "%AHKDIR%\Scripts"
SET AppEditText=%ProgramFiles%
SET wuBIN=%TCTOOLS%\wuBIN
START "" "%TCMD%" /i="%TCDATA%\wincmd.ini" /F="%TCDATA%\wcx_ftp.ini"
GOTO:EOF
:GET_PATH
SET LocalDrive=%~d1