TC全称是Total Commander,是代替资源管理器的神器级软件(附官方网址)
最大特点就是接口十分丰富,还有众多插件!给了用户很大的自主权。
其9.0 版本开始又新增了非常重要的接口,软件安装后,在 history.txt 里有几行更新说明(见文章末尾),可以用SendMessage命令获取信息, 消息号是WM_USER+50(即1074),wParam则是更新说明里的内容,
下面是我简单整理后的结果(带*是实用功能):
1-29是获取控件id,以下内容分别是:消息号、控件名称、说明
- 1/2 TMyListBox2/1 左/右侧列表
- 3/4* 参考上面 来源/对面文件列表
- 5/6 THeaderClick1/2 左/右标签
- 7/8 TMyPanel5/8 左/右状态栏
- 9/10* TPathPanel1/2 左/右路径
- 11/12 TMyPanel6/9 左/右磁盘信息
- 13/14 TMyComboBox2/3 左/右驱动
- 15/16/17 TMyPanel4/7/2 左/右/底
- 18/19 TMyListBox1/2 左/右树
- 20 TMyComboBox1 命令行
- 21 TMyPanel3 命令行当前路径
- 22 TInEdit1 命令行内容
- 23 TPanel1
- 24/25 左/右驱动(待核实)
- 26/27 TMyTabControl1/2 左/右标签(待核实)
- 28 命令按钮(F1等)
- 29 未知
1000以上则是获取其他信息,分别是消息号和返回内容,
- 1000* 1/2 来源为左/右面板
- 1001/1002 左/右面板当前文件总数(部分可能被过滤了)
- 1003/1004 左/右面板总文件总数(无视过滤)
- 1005/1006* 左/右面板选中文件数量
- 1007/1008* 左/右面板当前光标的文件序号
- 1009/1010 左/右未知
- 1011/1012* 左/右第一个文件的序号
以上接口,能判断来源是左/右窗口的是1000,
获取信息的方法里,除了3/4能获取来源/目标文件列表控件,
其他方法都是针对左/右窗口的,来源/目标需要依据1000来区分。
获取来源当前光标文件名的逻辑:
- 3获取当前控件A
- ControlGetList获取所有文件内容B(每行一个文件,每列是文件的属性信息,以Tab分隔),注意:第一行是返回上一级的信息。
- 1007/1008获取文件序号C(因为上面的红字,这里获取的序号要+1)
- 根据B和C获取文件信息S,StrSplit(S, A_Tab)就可以获取文件的所有信息,文件名通常是[1]
根据这些接口,写了一系列获取信息的函数如下:
get(n) ;NOTE 核心接口函数 { Return SendMessage(1074, n, 0, , "Ahk_class TTOTAL_CMD") } ctlDirSrc() ;来源:路径控件 { Return get(8+get(1000)) } ctlDirTrg() { Return get(11-get(1000)) } um_DirSrc() ;来源:目录路径(代替C2) { Return ControlGetText(ctlDirSrc(), "Ahk_class TTOTAL_CMD").dir() } um_DirTrg() { Return ControlGetText(ctlDirTrg(), "Ahk_class TTOTAL_CMD").dir() } um_ArrCurrentSrc() ;来源:光标文件信息(arr) { Return arrFileCurrent(3) } um_arrCurrentTrg() { Return arrFileCurrent(4) } um_FileNameSrc() ;来源:光标文件名 { Return um_ArrCurrentSrc()[1] } um_FileNameTrg() { Return um_ArrCurrentTrg()[1] } um_FilePathSrc() ;来源:光标文件完整路径 { Return um_DirSrc() . "" . um_FileNameSrc() } um_FilePathTrg() { Return um_DirTrg() . "" . um_FileNameTrg() } um_CopyNamesToClip() ;复制选中文件名(这块暂时还不能直接获取,得借用剪切板) { Clipboard := "" cm_CopyNamesToClip() ;复制名称 If ClipWait(0.2) Return Clipboard } um_CopyFullNamesToClip() ;复制选中文件路径 { Clipboard := "" cm_CopyFullNamesToClip() If ClipWait(0.2) Return Clipboard } ;获取光标文件的信息(arr) ;Src为3,Trg为4 arrFileCurrent(tp:=3) { str := ControlGetList("", get(tp), "Ahk_class TTOTAL_CMD") ;所有文件列表 idx := get(1006+get(1000)) + 1 ;因为前面有个返回上一级的行 Loop Parse, str, "`n", "`r" { If (A_Index = idx) Return StrSplit(A_LoopField, A_Tab) } }
更新文件相关内容:
08.06.16 Release Total Commander 9.0 beta 1 (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1011/1012 to get index of first file in list (-1 if there are no files) (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1009/1010 to get index of first item (0 if there is no updir, 1 otherwise) (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1007/1008 to get index of current item (caret) (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1005/1006 to get total number of selected items (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1003/1004 to get total number of items (including those hidden by quick filter (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1001/1002 to get number of items in left/right list (32/64)
08.06.16 Added: Send WM_USER+50 with wparam set to 1000 to get active panel: 1=left, 2=right (32/64)
08.06.16 Added: Send WM_USER+50 with wparam=1..29 -> returns window handle of control. Controls are: 1=leftlist, 2=rightlist, 3=active list, 4=inactive list, 5=leftheader, 6=rightheader, 7=leftsize, 8=rightsize, 9=leftpath, 10=rightpath, 11=leftinfo, 12=rightinfo, 13=leftdrives, 14=rightdrives, 15=leftpanel, 16=rightpanel, 17=bottompanel, 18=lefttree, 19=righttree, 20=cmdline, 21=curdirpanel, 22=inplaceedit, 23=splitpanel, 24=leftdrivepanel, 25=rightdrivepanel, 26=lefttabs, 27=righttabs, 28=buttonbar, 29=buttonbarvertical (32/64)