 return
 ; <ToggleTC> {{{1
 <ToggleTC>:
-	IfWinExist,AHK_CLASS TTOTAL_CMD
-	{
-		WinGet,AC,MinMax,AHK_CLASS TTOTAL_CMD
-		If Ac = -1
-			Winactivate,AHK_ClASS TTOTAL_CMD
-		Else
-		Ifwinnotactive,AHK_CLASS TTOTAL_CMD
-			Winactivate,AHK_CLASS TTOTAL_CMD
-		Else
-			Winminimize,AHK_CLASS TTOTAL_CMD
-	}
-	Else
-	{
-		Run,%TCPath%
-		Loop,4
-		{
-			IfWinNotActive,AHK_CLASS TTOTAL_CMD
-				WinActivate,AHK_CLASS TTOTAL_CMD
-			Else
-				Break
-			Sleep,500
-		}
-	}
+    IfWinExist,AHK_CLASS TTOTAL_CMD
+    {
+        WinGet,AC,MinMax,AHK_CLASS TTOTAL_CMD
+        If Ac = -1
+            Winactivate,AHK_ClASS TTOTAL_CMD
+        Else
+        Ifwinnotactive,AHK_CLASS TTOTAL_CMD
+            Winactivate,AHK_CLASS TTOTAL_CMD
+        Else
+            Winminimize,AHK_CLASS TTOTAL_CMD
+    }
+    Else
+    {
+        Run,%TCPath%
+        Loop,4
+        {
+            IfWinNotActive,AHK_CLASS TTOTAL_CMD
+                WinActivate,AHK_CLASS TTOTAL_CMD
+            Else
+                Break
+            Sleep,500
+        }
+    }
     ;settimer,AUTHTC,on
-	;emptymem()
+    ;emptymem()
 return
 
 ;激活TC
 <FocusTC>:
 {
-	IfWinExist,AHK_CLASS TTOTAL_CMD
-		Winactivate,AHK_ClASS TTOTAL_CMD
-	Else
-	{
-		Run,%TCPath%
-		Loop,4
-		{
-			IfWinNotActive,AHK_CLASS TTOTAL_CMD
-				WinActivate,AHK_CLASS TTOTAL_CMD
-			Else
-				Break
-			Sleep,500
-		}
-	}
-	return
+    IfWinExist,AHK_CLASS TTOTAL_CMD
+        Winactivate,AHK_ClASS TTOTAL_CMD
+    Else
+    {
+        Run,%TCPath%
+        Loop,4
+        {
+            IfWinNotActive,AHK_CLASS TTOTAL_CMD
+                WinActivate,AHK_CLASS TTOTAL_CMD
+            Else
+                Break
+            Sleep,500
+        }
+    }
+    return
 }
 
 ;激活TC，并定位到命令行
 <FocusTCCmd>:
 {
-	gosub,<FocusTC>
-	SendPos(4003)
-	return
+    gosub,<FocusTC>
+    SendPos(4003)
+    return
 }
 
 AUTHTC:

<TC_7>:
<TC_8>:
<TC_9>:
	Vim_HotKeyCount :=
return
; TTOTAL_CMD_CheckMode()
TTOTAL_CMD_CheckMode()
{
	WinGet,MenuID,ID,AHK_CLASS #32768
	If MenuID
		return True
	ControlGetFocus,ctrl,AHK_CLASS TTOTAL_CMD
;	If RegExMatch(ctrl,TInEdit)
;		Return True
;	If RegExMatch(ctrl,TCEdit)
;		Return True

	Ifinstring,ctrl,RichEdit20W1
		Return False
	Ifinstring,ctrl,%TCListBox% 
		Return False
	Return True
}
<ExcSubOK>:
	Tooltip
return
; <Esc_TC> {{{1
<Normal_Mode_TC>:
	Send,{Esc}
    vim.Mode("normal","TTOTAL_CMD")
	;emptymem()
return
; <QuickSearch> {{{1
<Search>:

﻿TotalCommander:
    Global tcconfig := GetINIObj(ConfigPath)
    Global TCPath   := tcconfig.GetValue("TotalCommander_Config","TCPath")
    Global TCINI    := tcconfig.GetValue("TotalCommander_Config","TCINI")

    If !FileExist(TCPath)
    {
        Process,Exist,totalcmd.exe
        If ErrorLevel
        {
            WinGet,TCPath,ProcessPath,ahk_pid %ErrorLevel%
        }
        Else
        {
            Process,Exist,totalcmd64.exe
            If ErrorLevel
                WinGet,TCPath,ProcessPath,ahk_pid %ErrorLevel%
        }
        If TCPath
            IniWrite,%TCPath%,%ConfigPath%,TotalCommander_Config,TCPath
    }

    If TCPath and Not FileExist(TCPath)
    {
        RegRead,TCDir,HKEY_CURRENT_USER,Software\Ghisler\Total Commander,InstallDir
        If FileExist(TCDir "\totalcmd.exe")
            l .= TCDir "\totalcmd.exe`n"
        If FileExist(TCDir "\totalcmd64.exe")
            l .= TCDir "\totalcmd64.exe`n"
        GUI,FindTC:Add,Edit,w300 ReadOnly R3,%TCDir%
        GUI,FindTC:Add,Button,w300 gTotalcomander_select_tc,TOTALCMD.EXE   (&A)
        GUI,FindTC:Add,Button,w300 gTotalcomander_select_tc64,TOTALCMD64.EXE (&S)
        GUI,FindTC:Add,Button,w300 gTotalcomander_select_tcdir,TC目录路径不对? (&D)
        GUI,FindTC:Show,,Total Commander 设置路径
    }

    If TCPath and not FileExist(TCINI)
    {
        SplitPath,TCPath,,dir
        TCINI := dir "\wincmd.ini"
        IniWrite,%TCINI%,%ConfigPath%,TotalCommander_Config,TCINI
    }

    
    ;添加将TC作为打开文件对话框的快捷键
    IniWriteIfNullValue(ConfigPath,"Global","*<ctrl>;","<FocusTCCmd>")

    If RegExMatch(TcPath,"i)totalcmd64\.exe$")
    {
        Global TCListBox := "LCLListBox"
        Global TCEdit := "Edit2"
        Global TInEdit := "TInEdit1"
        GLobal TCPanel1 := "Window1"
        Global TCPanel2 := "Window11"
    }
    Else
    {
        Global TCListBox := "TMyListBox"
        Global TCEdit := "Edit1"
        Global TInEdit := "TInEdit1"
        Global TCPanel1 := "TPanel1"
        Global TCPanel2 := "TMyPanel8"
    }
    Global Mark := []
    Global NewFiles := []
    vim.Comment("<Normal_Mode_TC>","返回正常模式")
    vim.Comment("<Insert_Mode_TC>","进入插入模式")
    vim.Comment("<ToggleTC>","打开/激活TC")
    vim.comment("<FocusTCCmd>","激活TC，并定位到命令行")

    vim.Comment("<azHistory>","a-z历史导航")
    vim.Comment("<DownSelect>","向下选择")
    vim.Comment("<UpSelect>","向上选择")
    vim.Comment("<Mark>","标记功能")
    vim.Comment("<ForceDelete>","强制删除")
    vim.Comment("<ListMark>","显示标记")
    vim.Comment("<Toggle_50_100Percent>","切换当前窗口显示状态50%~100%")
    vim.Comment("<WinMaxLeft>","最大化左侧窗口")
    vim.Comment("<WinMaxRight>","最大化右侧窗口")
    vim.Comment("<GoLastTab>","切换到最后一个标签")
    vim.Comment("<CopyNameOnly>","只复制文件名，不含扩展名")
    vim.Comment("<GotoLine>","移动到[count]行，默认第一行")
    vim.Comment("<LastLine>","移动到[count]行，默认最后一行")
    vim.Comment("<Half>","移动到窗口中间行")
    vim.Comment("<CreateNewFile>","文件模板")
    vim.Comment("<GoToParentEx>","返回到上层文件夹，可返回到我的电脑")
    vim.Comment("<AlwayOnTop>","设置TC顶置")
    vim.comment("<OpenDriveThis>","打开驱动器列表:本侧")
    vim.comment("<OpenDriveThat>","打开驱动器列表:另侧")
    vim.comment("<MoveDirectoryHotlist>","移动到常用文件夹")
    vim.comment("<CopyDirectoryHotlist>","复制到常用文件夹")
    vim.comment("<GotoPreviousDirOther>","后退另一侧")
    vim.comment("<GotoNextDirOther>","前进另一侧")
    vim.comment("<Search>","连续搜索")

    vim.mode("normal","TQUICKSEARCH")
    vim.map("J","<Down>","TQUICKSEARCH")
    vim.map("K","<Up>","TQUICKSEARCH")
    ;vim.map("<esc>","<Normal_Mode_TC>","TQUICKSEARCH")

    vim.mode("insert","TTOTAL_CMD")
    vim.SetTimeOut(800,"TTOTAL_CMD")
    vim.map("<esc>","<Normal_Mode_TC>","TTOTAL_CMD")
    vim.mode("Search","TTOTAL_CMD")
    vim.map("<esc>","<Normal_Mode_TC>","TTOTAL_CMD")

    vim.mode("normal","TTOTAL_CMD")

    ;复制/移动到右侧 f取file的意思 filecopy
    vim.map("fc","<cm_CopyOtherpanel>","TTOTAL_CMD")
    vim.map("fx","<cm_MoveOnly>","TTOTAL_CMD")

    ;使用队列复制/移动到右侧 q-queue,fcq会影响对fc的使用，改用fqc/fqx的方式
    vim.map("fqc","<CopyUseQueues>","TTOTAL_CMD")
    vim.map("fqx","<MoveUseQueues>","TTOTAL_CMD")

    ;ff复制到剪切板 fz剪切到剪切板 fv粘贴
    vim.map("ff","<cm_CopyToClipboard>","TTOTAL_CMD")
    vim.map("fz","<cm_CutToClipboard>","TTOTAL_CMD")
    vim.map("fv","<cm_PasteFromClipboard>","TTOTAL_CMD")

    ;fb复制到收藏夹某个目录，fd移动到收藏夹的某个目录
    vim.map("fb","<CopyDirectoryHotlist>","TTOTAL_CMD")
    vim.map("fd","<MoveDirectoryHotlist>","TTOTAL_CMD")
    vim.map("ft","<cm_SyncChangeDir>","TTOTAL_CMD")
    vim.map("<shift>f","<Search>","TTOTAL_CMD")
    vim.map("gh","<GotoPreviousDirOther>","TTOTAL_CMD")
    vim.map("gl","<GotoNextDirOther>","TTOTAL_CMD")
    vim.map("<shift>vh","<cm_SwitchIgnoreList>","TTOTAL_CMD")
    vim.map("0","<0>","TTOTAL_CMD")
    vim.map("1","<1>","TTOTAL_CMD")
    vim.map("2","<2>","TTOTAL_CMD")
    vim.map("3","<3>","TTOTAL_CMD")
    vim.map("4","<4>","TTOTAL_CMD")
    vim.map("5","<5>","TTOTAL_CMD")
    vim.map("6","<6>","TTOTAL_CMD")
    vim.map("7","<7>","TTOTAL_CMD")
    vim.map("8","<8>","TTOTAL_CMD")
    vim.map("9","<9>","TTOTAL_CMD")
    vim.map("k","<up>","TTOTAL_CMD")
    vim.map("K","<upSelect>","TTOTAL_CMD")
    vim.map("j","<down>","TTOTAL_CMD")
    vim.map("J","<downSelect>","TTOTAL_CMD")
    vim.map("h","<left>","TTOTAL_CMD")
    vim.map("H","<cm_GotoPreviousDir>","TTOTAL_CMD")
    vim.map("l","<right>","TTOTAL_CMD")
    vim.map("L","<cm_GotoNextDir>","TTOTAL_CMD")
    vim.map("I","<CreateNewFile>","TTOTAL_CMD")
    vim.map("i","<Insert_Mode_TC>","TTOTAL_CMD")
    vim.map("d","<cm_DirectoryHotlist>","TTOTAL_CMD")
    vim.map("D","<cm_OpenDesktop>","TTOTAL_CMD")
    vim.map("e","<cm_ContextMenu>","TTOTAL_CMD")
    vim.map("E","<cm_ExeCuteDOS>","TTOTAL_CMD")
    vim.map("n","<azHistory>","TTOTAL_CMD")
    vim.map("m","<Mark>","TTOTAL_CMD")
    vim.map("M","<Half>","TTOTAL_CMD")
    vim.map("'","<ListMark>","TTOTAL_CMD")
    vim.map("u","<GoToParentEx>","TTOTAL_CMD")
    vim.map("U","<cm_GoToRoot>","TTOTAL_CMD")
    vim.map("o","<cm_LeftOpenDrives>","TTOTAL_CMD")
    vim.map("O","<cm_RightOpenDrives>","TTOTAL_CMD")
    vim.map("q","<cm_SrcQuickView>","TTOTAL_CMD")
    vim.map("r","<cm_RenameOnly>","TTOTAL_CMD")
    vim.map("R","<cm_MultiRenameFiles>","TTOTAL_CMD")
    vim.map("x","<cm_Delete>","TTOTAL_CMD")
    vim.map("X","<ForceDelete>","TTOTAL_CMD")
    vim.map("w","<cm_List>","TTOTAL_CMD")
    vim.map("y","<cm_CopyNamesToClip>","TTOTAL_CMD")
    vim.map("Y","<cm_CopyFullNamesToClip>","TTOTAL_CMD")
    vim.map("P","<cm_PackFiles>","TTOTAL_CMD")
    vim.map("p","<cm_UnpackFiles>","TTOTAL_CMD")
    vim.map("t","<cm_OpenNewTab>","TTOTAL_CMD")
    vim.map("T","<cm_OpenNewTabBg>","TTOTAL_CMD")
    vim.map("/","<cm_ShowQuickSearch>","TTOTAL_CMD")
    vim.map("?","<cm_SearchFor>","TTOTAL_CMD")
    vim.map("[","<cm_SelectCurrentName>","TTOTAL_CMD")
    vim.map("{","<cm_UnselectCurrentName>","TTOTAL_CMD")
    vim.map("]","<cm_SelectCurrentExtension>","TTOTAL_CMD")
    vim.map("}","<cm_UnSelectCurrentExtension>","TTOTAL_CMD")
    vim.map("\","<cm_ExchangeSelection>","TTOTAL_CMD")
    vim.map("|","<cm_ClearAll>","TTOTAL_CMD")
    vim.map("-","<cm_SwitchSeparateTree>","TTOTAL_CMD")
    vim.map("=","<cm_MatchSrc>","TTOTAL_CMD")
    vim.map(";","<cm_FocusCmdLine>","TTOTAL_CMD")
    vim.map(":","<cm_FocusCmdLine>","TTOTAL_CMD")
    vim.map("G","<LastLine>","TTOTAL_CMD")
    vim.map("ga","<cm_CloseAllTabs>","TTOTAL_CMD")
    vim.map("gg","<GoToLine>","TTOTAL_CMD")
    vim.map("g$","<LastLine>","TTOTAL_CMD")

    ;与vim保持一致
    vim.map("gt","<cm_SwitchToNextTab>","TTOTAL_CMD")
    vim.map("gT","<cm_SwitchToPreviousTab>","TTOTAL_CMD")
    vim.map("gc","<cm_CloseCurrentTab>","TTOTAL_CMD")
    vim.map("gb","<cm_OpenDirInNewTabOther>","TTOTAL_CMD")
    vim.map("ge","<cm_Exchange>","TTOTAL_CMD")
    vim.map("gw","<cm_ExchangeWithTabs>","TTOTAL_CMD")
    vim.map("g1","<cm_SrcActivateTab1>","TTOTAL_CMD")
    vim.map("g2","<cm_SrcActivateTab2>","TTOTAL_CMD")
    vim.map("g3","<cm_SrcActivateTab3>","TTOTAL_CMD")
    vim.map("g4","<cm_SrcActivateTab4>","TTOTAL_CMD")
    vim.map("g5","<cm_SrcActivateTab5>","TTOTAL_CMD")
    vim.map("g6","<cm_SrcActivateTab6>","TTOTAL_CMD")
    vim.map("g7","<cm_SrcActivateTab7>","TTOTAL_CMD")
    vim.map("g8","<cm_SrcActivateTab8>","TTOTAL_CMD")
    vim.map("g9","<cm_SrcActivateTab9>","TTOTAL_CMD")
    vim.map("g0","<GoLastTab>","TTOTAL_CMD")
    vim.map("sn","<cm_SrcByName>","TTOTAL_CMD")
    vim.map("se","<cm_SrcByExt>","TTOTAL_CMD")
    vim.map("ss","<cm_SrcBySize>","TTOTAL_CMD")
    vim.map("sd","<cm_SrcByDateTime>","TTOTAL_CMD")
    vim.map("sr","<cm_SrcNegOrder>","TTOTAL_CMD")
    vim.map("s1","<cm_SrcSortByCol1>","TTOTAL_CMD")
    vim.map("s2","<cm_SrcSortByCol2>","TTOTAL_CMD")
    vim.map("s3","<cm_SrcSortByCol3>","TTOTAL_CMD")
    vim.map("s4","<cm_SrcSortByCol4>","TTOTAL_CMD")
    vim.map("s5","<cm_SrcSortByCol5>","TTOTAL_CMD")
    vim.map("s6","<cm_SrcSortByCol6>","TTOTAL_CMD")
    vim.map("s7","<cm_SrcSortByCol7>","TTOTAL_CMD")
    vim.map("s8","<cm_SrcSortByCol8>","TTOTAL_CMD")
    vim.map("s9","<cm_SrcSortByCol9>","TTOTAL_CMD")
    vim.map("s0","<cm_SrcUnsorted>","TTOTAL_CMD")
    vim.map("v","<cm_SrcCustomViewMenu>","TTOTAL_CMD")
    vim.map("Vb","<cm_VisButtonbar>","TTOTAL_CMD")
    vim.map("Vd","<cm_VisDriveButtons>","TTOTAL_CMD")
    vim.map("Vo","<cm_VisTwoDriveButtons>","TTOTAL_CMD")
    vim.map("Vr","<cm_VisDriveCombo>","TTOTAL_CMD")
    vim.map("Vc","<cm_VisDriveCombo>","TTOTAL_CMD")
    vim.map("Vt","<cm_VisTabHeader>","TTOTAL_CMD")
    vim.map("Vs","<cm_VisStatusbar>","TTOTAL_CMD")
    vim.map("Vn","<cm_VisCmdLine>","TTOTAL_CMD")
    vim.map("Vf","<cm_VisKeyButtons>","TTOTAL_CMD")
    vim.map("Vw","<cm_VisDirTabs>","TTOTAL_CMD")
    vim.map("Ve","<cm_CommandBrowser>","TTOTAL_CMD")
    vim.map("zz","<Toggle_50_100Percent>","TTOTAL_CMD")
    vim.map("zi","<WinMaxLeft>","TTOTAL_CMD")
    vim.map("zo","<WinMaxRight>","TTOTAL_CMD")
    vim.map("zt","<AlwayOnTop>","TTOTAL_CMD")
    vim.map("zn","<cm_Minimize>","TTOTAL_CMD")
    vim.map("zm","<cm_Maximize>","TTOTAL_CMD")
    vim.map("zr","<cm_Restore>","TTOTAL_CMD")
    vim.map("zv","<cm_VerticalPanels>","TTOTAL_CMD")
    vim.map("zv","<cm_VerticalPanels>","TTOTAL_CMD")
    vim.map(".","<Repeat>","TTOTAL_CMD")
    /*
    ;vim.map("zs","<TransParent>","TTOTAL_CMD")
    KeyList := vim.listKey("TTOTAL_CMD")
    GUI,Add,ListView,w300 h500,a
    Loop,Parse,KeyList,`n
    {
        LV_Add("",A_LoopField)
    }
    GUI,Show ,w310 h510
    */
    ;; 默认按键完
    ReadNewFile()
    GoSub,TCCOMMAND
return

<TC_0>:
<TC_1>:
<TC_2>:
