[AHK]在TC中按热键调用Everything搜索当前目录

105 篇文章 5 订阅
92 篇文章 3 订阅

方案0:简单4行代码搞定。

#f::
	SendMessage 1074, 21, 0, , ahk_class TTOTAL_CMD
	ControlGetText, varPathInTC, , ahk_id %ErrorLevel%
	StringReplace, varPathInTC, varPathInTC, >, "\ "
	run "D:\Everything\Everything.exe" -search %varPathInTC% 
return

;注释:
; MsgBox curdirpanel_id: %ErrorLevel% ; e.g.: 7014276 
        ;(The controls' current ID, a random number, valid for the time being, will change on next situation)
	;参考 :https://ghisler.ch/board/viewtopic.php?t=44451 
	;AHK-L v1.1.22.09:
	;ControlGetText, OutputVar [, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
	;To operate upon a control's HWND (window handle), 
	;leave the Control parameter blank 
	;and specify <<<ahk_id %ControlHwnd%>>> for the WinTitle parameter

 

方案1:

2011年我在 https://www.ghisler.ch/wiki/index.php?title=AutoHotkey:_Send_a_user_command_to_Total_Commander 

发布的一个方案,当时的方案不支持Unicode,现在完善下(TC官网wiki的登录密码,我忘记了重置邮件又收不到,暂时没法更新到wiki上)。

先要在TC中定义自定义命令em_Everything,然后向TC发送消息去调用自定义命令。

可以直接在usercmd.ini文件中定义em_Everything的:

[em_Everything]
button=D:\Everything\Everything.exe
cmd=D:\Everything\Everything.exe
param=-search "%P  " 
path=D:\Everything\
menu=搜索当前目录

也可以如下图示,创建em_Everything:

#z::
TC_SendData("em_Everything") ; User Command
return

TC_SendData(Cmd) {
   VarSetCapacity(CopyDataStruct, A_PtrSize * 3)
   If( A_IsUnicode ) {
      VarSetCapacity( cmdU, StrPut(cmd, "cp0"),0) 
      Loop, % StrLen(cmd)
         NumPut( Asc(SubStr(cmd, A_Index, 1)), cmdU, A_Index - 1, "Char")
   }
   NumPut(Asc("E") + 256 * Asc("M"), CopyDataStruct,0 )
   NumPut( StrLen(cmd), CopyDataStruct, A_PtrSize )
   NumPut((A_IsUnicode ? &cmdU : &cmd), CopyDataStruct, A_PtrSize * 2)
   SendMessage, 0x4A,%A_ScriptHwnd%, &CopyDataStruct,, ahk_class TTOTAL_CMD
}


 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值