[Autohotkey] Set Path In TC

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

Moderators: white, Hacker, petermad, Stefan2

Post Reply
valuex
Junior Member
Junior Member
Posts: 25
Joined: 2014-12-25, 13:53 UTC

[Autohotkey] Set Path In TC

Post by *valuex »

The below AHK V2 script can help you to set the path in TC by sending message.

Code: Select all

;https://www.ghisler.ch/board/viewtopic.php?p=277574#256573
/*
The complete syntax is in fact : 
<Left>`r<Right>\0                       ; eg:  D:\xxx\   `r  E:\xxx\  \0
<Source>`r<Target>\0S                   ; eg:  D:\xxx\   `r  E:\xxx\  \0
<Left>`r<Right>\0T open in new Tab      ; eg:  D:\xxx\   `r  E:\xxx\  \0T
*/
TC_SetLeftPath(inpath) 
{
    ; inpath should be ended with \
    newPath:=inpath . "`r"
    TC_SetPath(newPath) 
}
TC_SetRightPath(inpath)
{
    ; inpath should be ended with \
    newPath:="`r" . inpath . "\0"
    TC_SetPath(newPath) 
}
TC_SetPath(userCommand) 
{
    ; https://www.autohotkey.com/boards/viewtopic.php?p=538463&sid=4471e03917209854441ac07ebdc70901#p538463
    static dwData := 17475  ;;Ord("C") +256*Ord("D")
    static WM_COPYDATA := 0x4A
    cbData := Buffer(StrPut(userCommand, 'CP0'))
    StrPut(userCommand, cbData, 'CP0')
    COPYDATASTRUCT := Buffer(A_PtrSize * 3)
    NumPut('Ptr', dwData, 'Ptr', cbData.size, 'Ptr', cbData.ptr, COPYDATASTRUCT)
    MsgResult:=SendMessage( WM_COPYDATA,, COPYDATASTRUCT,, 'ahk_class TTOTAL_CMD')
    return MsgResult
}
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6495
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: [Autohotkey] Set Path In TC

Post by *Horst.Epp »

Sending data is fine, but I never need this in scripting
as there is always the way to control the left / right path of the active TC
using a command line with the /O switch.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
TC 11.03 x64 / x86
Everything 1.5.0.1373a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
Fla$her
Power Member
Power Member
Posts: 2318
Joined: 2020-01-18, 04:03 UTC

Re: [Autohotkey] Set Path In TC

Post by *Fla$her »

2Horst.Epp
There is a big difference in speed, given the temporary creation of a new instance. I always give preference to TCFS2.exe /ef tcd(), except in cases with /P for a folder.
Overquoting is evil! 👎
Post Reply