tc的快搜后需要esc一下来退出快搜才能执行命令,我经常忘了按导致一些比如复制全路径的命令没有执行成功
因而做了这个ahk工具来强化,可以实现自动退出快搜,以及显示tc中复制到的内容
下面是源码
TC_EMC( cmd, wID="ahk_class TTOTAL_CMD", activateWin=FALSE, showMsg=FALSE ) {
TC_Activate( wID, activateWin, showMsg, cmd )
TC_SendWMCopyData( "EM", cmd, params:="", wID )
Return
}
TC_Activate( byRef wID, activateWin=TRUE, showMsg=TRUE, cmd="" ) {
wID:=QueryWinID(wID, TRUE)
if(!activateWin )
Return FALSE
if( showMsg )
MsgBox,,%A_ThisFunc%, % "Activating TC" ( cmd ? ", for command: " cmd "`n" : "`n"), 1
WinActivate, ahk_id %wID%
Return TRUE
}
QueryWinID( aWin="A", canExist=FALSE, winText="", notTitle="", notText="" ) {
if( !(retVal:=WinActiveA( aWin, winText, notTitle, notText )) )
retVal:=( !canExist ? 0 : WinExistA( aWin, winText, notTitle, notText ))
Return retVal
}
WinActiveA( aWin="", winText="", notTitle="", notText="" ) {
Return WinActive( (aWin+0 ? "ahk_id " aWin : aWin), winText, notTitle, notText )
}
WinExistA( aWin="", winText="", notTitle="", notText="" ) {
Return WinExist( (aWin+0 ? "ahk_id " aWin : aWin), winText, notTitle, notText )
}
TC_SendWMCopyData( cmdType, byRef cmd, byRef addParams="", aWin="A" ) {
aWin := (aWin+0) ? aWin : WinExist(aWin)
; aWin := aWin ? aWin : WinExist("ahk_class TTOTAL_CMD")
Critical
VarSetCapacity( CopyDataStruct, A_PtrSize * 3 )
if( A_IsUnicode )
{
VarSetCapacity( cmdA, StrPut(cmd, "cp0") + 1)
Loop, % StrLen(cmd)
NumPut( Asc(SubStr(cmd, A_Index, 1)), cmdA, A_Index - 1, "Char")
NumPut( 0, cmdA, StrLen(cmd), "Char") ; Add the '\0' char to the end of the string and terminate it, otherwise, changes are that unwanted char present.
}
NumPut( Asc(SubStr(cmdType,1,1)) + 256 * Asc(SubStr(cmdType,2,1)), CopyDataStruct )
NumPut( StrLen(cmd) + (cmdType="CD" ? 5 : 1), CopyDataStruct, A_PtrSize )
NumPut((A_IsUnicode ? &cmdA : &cmd), CopyDataStruct, A_PtrSize * 2)
NumPut( &cmdA, CopyDataStruct, A_PtrSize * 2)
Loop, % (cmdType=="CD" ? 2 : 0)
NumPut( Asc(SubStr(addParams, A_Index, 1)), (A_IsUnicode ? cmdA : cmd), (StrLen(cmd) + A_Index), "Char" )
SendMessage, 0x4A,, &CopyDataStruct,, ahk_id %aWin%
Return
}
;改caps切换应用避免tab问题
capslock & 1:: send,#1
capslock & 2:: send,#2
capslock & 3:: send,#3
capslock & 4:: send,#4
capslock & 5:: send,#5
capslock & 6:: send,#6
capslock & 7:: send,#7
capslock & 8:: send,#8
removett:
tooltip
return
ks(num,em:="",close:="",clip:=1){
sendinput,{Esc}
sleep 200
if (num>0)
SendMessage 1075,%num%,, ,ahk_class TTOTAL_CMD
else if (!em)
TC_EMC(em)
if (clip=1){
ClipWait,1
tooltip,% Clipboard
}
if (close=1)
sendinput,{Esc}
SetTimer,removett,1000
return
}
;快搜加强
#IfWinActive QUICKSEARCH ahk_class TQUICKSEARCH
^+c:: ks(2018)
^+n:: ks(2017)
^+p:: ks(2029)
^+m:: ks(0,"em_CopyJustFileName")
^e:: ks(0,"em_ExtractAndEnterDir")
锟斤拷