Update GKey.ahk

Update GKey.ahk

#SingleInstance, Force
#NoTrayIcon

global msg

AddAction("a", "RunNotepad", "用记事本显示剪切板内容")
AddAction("b", "ShowClipboard", "显示剪切板内容")
AddAction("c", "ShowIp", "显示IP")
AddAction("d", "RunClipboardWithMintty", "运行剪切板的命令")
AddAction("z", "test", "测试")

MsgBox, %msg%

ExitApp

AddAction(key, label, info)
{
    msg .= key "  =>  " info "`n"
    HotKey, %key%, %label%
}

RunWithBash(command)
{
    shell := ComObjCreate("WScript.Shell")
    exec := shell.Exec("bash -c '" command " | iconv -f utf-8 -t gbk -c")
    return exec.StdOut.ReadAll()
}

RunWithCmd(command)
{
    shell := ComObjCreate("WScript.Shell")
    exec := shell.Exec(ComSpec " /C " command)
    return exec.StdOut.ReadAll()
}

; ===========

RunNotepad:
    Run, notepad
    Send, ^v
    ExitApp
return

ShowClipboard:
    MsgBox, %clipboard%
    ExitApp
return

ShowIp:
    MsgBox, %A_IPAddress1%`n%A_IPAddress2%`n%A_IPAddress3%`n%A_IPAddress4%
    ExitApp
return

RunClipboardWithMintty:
	MsgBox % clipboard
    ;MsgBox % RunWithBash(clipboard)
    ;Run, mintty -e sh -c '%clipboard%; read'
    Run % "mintty -e sh -c '" clipboard "; read'"
	ExitApp
return

test:
    MsgBox, test
    ExitApp
return

#SingleInstance, Force
#NoTrayIcon

msg .= "a  =>  打开记事本并粘贴`n"
msg .= "b  =>  显示剪切板内容`n"
msg .= "c  =>  显示IP`n"
msg .= "d  =>  使用mintty运行剪切板的命令`n"
msg .= "e  =>  测试`n"

HotKey, a, RunNotepad
HotKey, b, ShowClipboard
HotKey, c, ShowIp
HotKey, d, RunClipboardMintty
HotKey, e, test
MsgBox, %msg%

ExitApp

RunNotepad:
    Run, notepad
    Send, ^v
    ExitApp
return

ShowClipboard:
    MsgBox, %clipboard%
    ExitApp
return

ShowIp:
    MsgBox, %A_IPAddress1%`n%A_IPAddress2%`n%A_IPAddress3%`n%A_IPAddress4%
    ExitApp
return

RunClipboardMintty:
	MsgBox % clipboard
    ;MsgBox % RunWithBash(clipboard)
    ;Run, mintty -e sh -c '%clipboard%; read'
    Run % "mintty -e sh -c '" clipboard "; read'"
	ExitApp
return

RunWithBash(command)
{
    shell := ComObjCreate("WScript.Shell")
    exec := shell.Exec("bash -c '" command " | iconv -f utf-8 -t gbk -c")
    return exec.StdOut.ReadAll()
}

RunWithCmd(command)
{
    shell := ComObjCreate("WScript.Shell")
    exec := shell.Exec(ComSpec " /C " command)
    return exec.StdOut.ReadAll()
}

test:
    MsgBox, test
    ExitApp
return


middle dot on right contrl + .

middle dot on right contrl + .

git-svn-id: d58676ab4b72c630679e33fc9c690d0f03588f5c@492 53b5f811-8420-8aa4-35af-336720f271cf

; Run this script with AutoHotkey, obtainable from www.autohotkey.com
; ƒ•ƒ•ƒ••••ƒƒƒƒƒƒ.......•

#?::ListHotKeys

CapsLock::RWin

;
;  Right-Control as the compose key
;
>^.::SendInput {U+2022}

^.::SendInput  {U+2022}
^'::SendInput  {U+00B4}
^>::SendInput  {U+00BB}
^!+|::SendInput {U+00A6}
^<::SendInput {U+00AB}

;
; Greek AltGr+letter  abcdeklmnoprstuxw
;                     αβγδεκλμνοπρστυχω
;
<^>!a::SendInput {U+03B1}
<^>!b::SendInput {U+03B2}
<^>!c::SendInput {U+03B3}
<^>!d::SendInput {U+03B4}
<^>!e::SendInput {U+03B5}
<^>!k::SendInput {U+03BA}
<^>!l::SendInput {U+03BB}
<^>!m::SendInput {U+03BC}
<^>!n::SendInput {U+03BD}
<^>!o::SendInput {U+03BF}
<^>!p::SendInput {U+03C0}
<^>!r::SendInput {U+03C1}
<^>!s::SendInput {U+03C3}
<^>!t::SendInput {U+03C4}
<^>!u::SendInput {U+03C5}
<^>!x::SendInput {U+03C7}
<^>!w::SendInput {U+03C9}
NumPadDiv::SendInput  {U+00F7}
NumPadMult::SendInput {U+00D7}

; Run this script with AutoHotkey, obtainable from www.autohotkey.com
; ƒ•ƒ•ƒ••••ƒƒƒƒƒƒ

#?::ListHotKeys

CapsLock::
SendInput {U+0192}
SetCapsLockState Off
return

^.::SendInput  {U+2022}
^'::SendInput  {U+00B4}
^>::SendInput  {U+00BB}
^!+|::SendInput {U+00A6}
^<::SendInput {U+00AB}

;
; Greek AltGr+letter  abcdeklmnoprstuxw
;                     αβγδεκλμνοπρστυχω
;
<^>!a::SendInput {U+03B1}
<^>!b::SendInput {U+03B2}
<^>!c::SendInput {U+03B3}
<^>!d::SendInput {U+03B4}
<^>!e::SendInput {U+03B5}
<^>!k::SendInput {U+03BA}
<^>!l::SendInput {U+03BB}
<^>!m::SendInput {U+03BC}
<^>!n::SendInput {U+03BD}
<^>!o::SendInput {U+03BF}
<^>!p::SendInput {U+03C0}
<^>!r::SendInput {U+03C1}
<^>!s::SendInput {U+03C3}
<^>!t::SendInput {U+03C4}
<^>!u::SendInput {U+03C5}
<^>!x::SendInput {U+03C7}
<^>!w::SendInput {U+03C9}
NumPadDiv::SendInput  {U+00F7}
NumPadMult::SendInput {U+00D7}


Fix vim.exe for non-ascii filename

Fix vim.exe for non-ascii filename

#NoTrayIcon
#NoEnv

arg = %1%

SplitPath, arg, filename, dir
SetWorkingDir, %dir%

SplitPath, A_ScriptName, , , , editor

if (InStr(filename, " "))
{
    filename = "%filename%"
}

Run, %A_ScriptDir%\bin\mintty -i "%A_ScriptFullPath%" -t "%arg%" -e /bin/wslbridge -t "%editor%" %filename%

#NoTrayIcon
#NoEnv

arg = %1%

SplitPath, arg, filename, dir
SetWorkingDir, %dir%

SplitPath, A_ScriptName, , , , editor

Run, %A_ScriptDir%\bin\mintty -i "%A_ScriptFullPath%" -t "%arg%" -e /bin/wslbridge -t "%editor%" "%filename%"


Files:  M Foobar2000.ahk

Files:  M Foobar2000.ahk

Foobar2000:
    global Foobar2000_name := "Foobar2000"
    global Foobar2000_class := "{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}"
    global Foobar2000_exe := "Foobar2000.exe"
    global Foobar2000_list_classnn := "{4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1"

    vim.comment("<Foobar2000_Search>", "打开搜索窗口")
    vim.comment("<Foobar2000_Tree>", "定位到目录窗口")
    vim.comment("<Foobar2000_List>", "定位到播放列表")
    vim.comment("<Foobar2000_ToggleShowInfo>", "显示/隐藏 按键提示")

    ; normal模式
    vim.SetWin(Foobar2000_name, Foobar2000_class, Foobar2000_exe)
    vim.mode("normal", Foobar2000_name)

    ;vim.map("i", "<Foobar2000_InsertMode>", Foobar2000_name)
    vim.map("<esc>", "<RemoveToolTip>", Foobar2000_name)

    vim.map("0", "<0>", Foobar2000_name)
    vim.map("1", "<1>", Foobar2000_name)
    vim.map("2", "<2>", Foobar2000_name)
    vim.map("3", "<3>", Foobar2000_name)
    vim.map("4", "<4>", Foobar2000_name)
    vim.map("5", "<5>", Foobar2000_name)
    vim.map("6", "<6>", Foobar2000_name)
    vim.map("7", "<7>", Foobar2000_name)
    vim.map("8", "<8>", Foobar2000_name)
    vim.map("9", "<9>", Foobar2000_name)

    vim.map("j", "<down>", Foobar2000_name)
    vim.map("k", "<up>", Foobar2000_name)
    vim.map("l", "<enter>", Foobar2000_name)
    vim.map("gg", "<home>", Foobar2000_name)
    vim.map("G", "<end>", Foobar2000_name)
    vim.map("<c-f>", "<pgdn>", Foobar2000_name)
    vim.map("<c-b>", "<pgup>", Foobar2000_name)
    vim.map("/", "<Foobar2000_Search>", Foobar2000_name)
    vim.map("t", "<Foobar2000_Tree>", Foobar2000_name)
    vim.map("m", "<Foobar2000_List>", Foobar2000_name)
    vim.map("n", "<Media_Next>", Foobar2000_name)
    vim.map("p", "<Media_Prev>", Foobar2000_name)
    vim.map("s", "<Media_Stop>", Foobar2000_name)
    vim.map("z", "<ShowHelp>", Foobar2000_name)

    vim.map("N", "<NextTab>", Foobar2000_name)
    vim.map("P", "<PrevTab>", Foobar2000_name)

    vim.map("``", "<Foobar2000_ToggleShowInfo>", Foobar2000_name)

    vim.BeforeActionDo("Foobar2000_ForceInsertMode", Foobar2000_name)
return

Foobar2000_ForceInsertMode()
{
    ControlGetFocus, ctrl
    ;MsgBox % ctrl
    if RegExMatch(ctrl, "Edit|Eslyric_Scintilla1")
        return true
    return false
}

<Foobar2000_Search>:
    send ^f
return

<Foobar2000_Tree>:
    ControlFocus, SysTreeView321
return

<Foobar2000_List>:
    ControlFocus, %Foobar2000_list_classnn%
return

<Foobar2000_ToggleShowInfo>:
    vim.GetWin(Foobar2000_name).SetInfo(!vim.GetWin(Foobar2000_name).info)
return

Foobar2000:
    global Foobar2000_name := "Foobar2000"
    global Foobar2000_class := "{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}"
    global Foobar2000_exe := "Foobar2000.exe"
    global Foobar2000_list_classnn := "{4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1"

    vim.comment("<Foobar2000_Search>", "打开搜索窗口")
    vim.comment("<Foobar2000_Tree>", "定位到目录窗口")
    vim.comment("<Foobar2000_List>", "定位到播放列表")
    vim.comment("<Foobar2000_ToggleShowInfo>", "显示/隐藏 按键提示")

    ; normal模式
    vim.SetWin(Foobar2000_name, Foobar2000_class, Foobar2000_exe)
    vim.mode("normal", Foobar2000_name)

    ;vim.map("i", "<Foobar2000_InsertMode>", Foobar2000_name)
    vim.map("<esc>", "<RemoveToolTip>", Foobar2000_name)

    vim.map("0", "<0>", Foobar2000_name)
    vim.map("1", "<1>", Foobar2000_name)
    vim.map("2", "<2>", Foobar2000_name)
    vim.map("3", "<3>", Foobar2000_name)
    vim.map("4", "<4>", Foobar2000_name)
    vim.map("5", "<5>", Foobar2000_name)
    vim.map("6", "<6>", Foobar2000_name)
    vim.map("7", "<7>", Foobar2000_name)
    vim.map("8", "<8>", Foobar2000_name)
    vim.map("9", "<9>", Foobar2000_name)

    vim.map("j", "<down>", Foobar2000_name)
    vim.map("k", "<up>", Foobar2000_name)
    vim.map("l", "<enter>", Foobar2000_name)
    vim.map("gg", "<home>", Foobar2000_name)
    vim.map("G", "<end>", Foobar2000_name)
    vim.map("<c-f>", "<pgdn>", Foobar2000_name)
    vim.map("<c-b>", "<pgup>", Foobar2000_name)
    vim.map("/", "<Foobar2000_Search>", Foobar2000_name)
    vim.map("t", "<Foobar2000_Tree>", Foobar2000_name)
    vim.map("m", "<Foobar2000_List>", Foobar2000_name)
    vim.map("n", "<Media_Next>", Foobar2000_name)
    vim.map("p", "<Media_Prev>", Foobar2000_name)
    vim.map("s", "<Media_Stop>", Foobar2000_name)
    vim.map("z", "<ShowHelp>", Foobar2000_name)

    vim.map("N", "<NextTab>", Foobar2000_name)
    vim.map("P", "<PrevTab>", Foobar2000_name)

    vim.map("``", "<Foobar2000_ToggleShowInfo>", Foobar2000_name)

    vim.BeforeActionDo("Foobar2000_ForceInsertMode", Foobar2000_name)
return

Foobar2000_ForceInsertMode()
{
    ControlGetFocus, ctrl
    ;MsgBox % ctrl
    if RegExMatch(ctrl, "Edit")
        return true
    return false
}

<Foobar2000_Search>:
    send ^f
return

<Foobar2000_Tree>:
    ControlFocus, SysTreeView321
return

<Foobar2000_List>:
    ControlFocus, %Foobar2000_list_classnn%
return

<Foobar2000_ToggleShowInfo>:
    vim.GetWin(Foobar2000_name).SetInfo(!vim.GetWin(Foobar2000_name).info)
return


fix for issue 15

fix for issue 15

TConly:
;=======================================================
	Global TCPath
	TCPath := "e:\Program Files\totalcmd\TOTALCMD.EXE"
	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("<azHistory>","a-z历史导航")
	vim.Comment("<DownSelect>","向下选择")
	vim.Comment("<UpSelect>","向上选择")
	vim.Comment("<Mark>","标记功能")
	vim.Comment("<ForceDelete>","强制删除")
	vim.Comment("<ListMark>","显示标记")
	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.mode("normal","TQUICKSEARCH")
	vim.map("J","<Down>","TQUICKSEARCH")
	;;默认按键(VIM)
	vim.map("K","<Up>","TQUICKSEARCH")
    ;vim.map("<esc>","<Normal_Mode_TC>","TQUICKSEARCH")
	vim.mode("insert","TTOTAL_CMD")
    vim.map("<esc>","<Normal_Mode_TC>","TTOTAL_CMD")
	vim.map("<lwin>e","<ToggleTC>")

    vim.mode("normal","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","<cm_DirectoryHistory>","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("G","<LastLine>","TTOTAL_CMD")
	vim.map("ga","<cm_CloseAllTabs>","TTOTAL_CMD")
	vim.map("gg","<GoToLine>","TTOTAL_CMD")
	vim.map("gn","<cm_SwitchToNextTab>","TTOTAL_CMD")
	vim.map("gp","<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","<cm_50Percent>","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("zs","<TransParent>","TTOTAL_CMD")
	vim.map(".","<Repeat>","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()
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,%TCListBox%
		Return False
	Return True
}
<ExcSubOK>:
	Tooltip
return
; <Esc_TC> {{{1
<Normal_Mode_TC>:
	Send,{Esc}
    vim.Mode("normal","TTOTAL_CMD")
	;emptymem()
return
; <insert_TC> {{{1
<Insert_Mode_TC>:
    vim.Mode("insert","TTOTAL_CMD")
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
		}
	}
    ;settimer,AUTHTC,on
	;emptymem()
return
AUTHTC:
    AUTHTC()
return
AUTHTC()
{
    WinGetText, string,ahk_class TNASTYNAGSCREEN
    If Strlen(string)
    {
        RegExMatch(string,"\d",idx)
        ControlClick,TButton%idx%,ahk_class TNASTYNAGSCREEN,,,,NA
        ;msgbox % idx
        settimer,AUTHTC,off
    }
}
; <azHistory> {{{1
<azHistory>:
		azhistory()
Return
azhistory()
{
	GoSub,<cm_DirectoryHistory>
	Sleep, 200
	if WinExist("ahk_class #32768")
	{
		SendMessage,0x01E1 ;Get Menu Hwnd
		hmenu := ErrorLevel
		if hmenu!=0
		{
			If Not RegExMatch(GetMenuString(Hmenu,1),".*[\\|/]$")
				Return
			Menu,sh,UseErrorLevel
			Menu,sh,add
			Menu,sh,deleteall
			If ErrorLevel
				return
			a :=
			itemCount := DllCall("GetMenuItemCount", "Uint", hMenu, "Uint")
			Loop %itemCount%
			{
				;a := chr(A_Index+64) . ">>" .  GetMenuString(Hmenu,A_Index-1)
				a :=  GetMenuString(Hmenu,A_Index-1) A_Tab "[&"  chr(A_Index+64) "]"
				Menu,SH,add,%a%,azSelect
				If not Mod(A_Index,3)
					Menu,SH,add
			}
			Send {Esc}
			ControlGetFocus,TLB,ahk_class TTOTAL_CMD
			ControlGetPos,xn,yn,,,%TLB%,ahk_class TTOTAL_CMD
			Menu,SH,show,%xn%,%yn%
			Return
		}
	}
}
GetMenuString(hMenu, nPos)
{
      VarSetCapacity(lpString, 256)
      length := DllCall("GetMenuString"
         , "UInt", hMenu
         , "UInt", nPos
         , "Str", lpString
         , "Int", 255
         , "UInt", 0x0400)
   	  return lpString
}
azSelect:
	azSelect()
Return
azSelect()
{
	nPos := A_ThisMenuItem
	nPos := Asc(Substr(nPos,-1,1)) - 64
	Winactivate,ahk_class TTOTAL_CMD
	Postmessage,1075,572,0,,ahk_class TTOTAL_CMD
	Sleep,200
	if WinExist("ahk_class #32768")
	{
		Loop %nPos%
			SendInput {Down}
		Send {enter}
	}
}
; <DownSelect> {{{1
<DownSelect>:
	Send +{Down}
return
; <upSelect> {{{1
<upSelect>:
	Send +{Up}
return
; <WinMaxLeft> {{{1
<WinMaxLeft>:
	WinMaxLR(true)
Return
; <WinMaxRight> {{{1
<WinMaxRight>:
	WinMaxLR(false)
Return
WinMaxLR(lr)
{
	If lr
	{
		ControlGetPos,x,y,w,h,%TCPanel2%,ahk_class TTOTAL_CMD
		ControlGetPos,tm1x,tm1y,tm1W,tm1H,%TCPanel1%,ahk_class TTOTAL_CMD
		If (tm1w < tm1h) ; 判断纵向还是横向 Ture为竖 false为横
		{
			ControlMove,%TCPanel1%,x+w,,,,ahk_class TTOTAL_CMD
		}
		else
			ControlMove,%TCPanel1%,0,y+h,,,ahk_class TTOTAL_CMD
		ControlClick, %TCPanel1%,ahk_class TTOTAL_CMD
		WinActivate ahk_class TTOTAL_CMD
	}
	Else
	{
		ControlMove,%TCPanel1%,0,0,,,ahk_class TTOTAL_CMD
		ControlClick,%TCPanel1%,ahk_class TTOTAL_CMD
		WinActivate ahk_class TTOTAL_CMD
	}
}
; <GoLastTab> {{{1
<GoLastTab>:
	GoSub,<cm_SrcActivateTab1>
	GoSub,<cm_SwitchToPreviousTab>
return
; <CopyNameOnly> {{{1
<CopyNameOnly>:
		CopyNameOnly()
Return
CopyNameOnly()
{
	clipboard :=
	GoSub,<cm_CopyNamesToClip>
	ClipWait
	If Not RegExMatch(clipboard,"^\..*")
		clipboard := RegExReplace(RegExReplace(clipboard,"\\$"),"\.[^\.]*$")
}
; <ForceDelete>  {{{1
; 强制删除
<ForceDelete>:
	Send +{Delete}
return
; <GotoLine> {{{1
; 转到[count]行,缺省第一行
<GotoLine>:
	Vim_HotKeyCount := vim.GetCount()
	If Vim_HotKeyCount
		GotoLine(Vim_HotKeyCount)
	Else
		GotoLine(1)
return
; <LastLine> {{{1
; 转到[count]行, 最后一行
<LastLine>:
	Vim_HotKeyCount := vim.GetCount()
	If Vim_HotKeyCount
		GotoLine(Vim_HotKeyCount)
	Else
		GotoLine(0)
return
GotoLine(Index)
{
	Vim_HotKeyCount := 0
	ControlGetFocus,Ctrl,AHK_CLASS TTOTAL_CMD
	If Index
	{
		Index--
		ControlGet,text,List,,%ctrl%,AHK_CLASS TTOTAL_CMD
		Stringsplit,T,Text,`n
		Last := T0 - 1
		If Index > %Last%
			Index := Last
		Postmessage,0x19E,%Index%,1,%Ctrl%,AHK_CLASS TTOTAL_CMD
	}
	Else
	{
		ControlGet,text,List,,%ctrl%,AHK_CLASS TTOTAL_CMD
		Stringsplit,T,Text,`n
		Last := T0 - 1
		PostMessage, 0x19E,  %Last% , 1 , %CTRL%, AHK_CLASS TTOTAL_CMD
	}
}
; <Half>  {{{1
; 移动到窗口中间
<Half>:
		Half()
Return
Half()
{
	winget,tid,id,ahk_class TTOTAL_CMD
	controlgetfocus,ctrl,ahk_id %tid%
	controlget,cid,hwnd,,%ctrl%,ahk_id %tid%
	controlgetpos,x1,y1,w1,h1,THeaderClick2,ahk_id %tid%
	controlgetpos,x,y,w,h,%ctrl%,ahk_id %tid%
	SendMessage,0x01A1,1,0,,ahk_id %cid%
	Hight := ErrorLevel
	SendMessage,0x018E,0,0,,ahk_id %cid%
	Top := ErrorLevel
	HalfLine := Ceil( ((h-h1)/Hight)/2 ) + Top
	PostMessage, 0x19E, %HalfLine%, 1, , AHK_id %cid%
}
; <Mark> {{{1
; 标记功能
<Mark>:
	Mark()
Return
Mark()
{
	vim.mode("insert")
	GoSub,<cm_FocusCmdLine>
	ControlGet,EditId,Hwnd,,AHK_CLASS TTOTAL_CMD
	ControlSetText,%TCEdit%,m,AHK_CLASS TTOTAL_CMD
	Postmessage,0xB1,2,2,%TCEdit%,AHK_CLASS TTOTAL_CMD
	SetTimer,<MarkTimer>,100
}
<MarkTimer>:
	MarkTimer()
Return
MarkTimer()
{
	ControlGetFocus,ThisControl,AHK_CLASS TTOTAL_CMD
	ControlGetText,OutVar,%TCEdit%,AHK_CLASS TTOTAL_CMD
	Match_TCEdit := "i)^" . TCEdit . "$"
	If Not RegExMatch(ThisControl,Match_TCEdit) OR Not RegExMatch(Outvar,"i)^m.?")
	{
		vim.mode("normal")
		Settimer,<MarkTimer>,Off
		Return
	}
	If RegExMatch(OutVar,"i)^m.+")
	{
		vim.mode("normal")
		SetTimer,<MarkTimer>,off
		ControlSetText,%TCEdit%,,AHK_CLASS TTOTAL_CMD
		ControlSend,%TCEdit%,{Esc},AHK_CLASS TTOTAL_CMD
		ClipSaved := ClipboardAll
		Clipboard :=
		Postmessage 1075, 2029, 0, , ahk_class TTOTAL_CMD
		ClipWait
		Path := Clipboard
		Clipboard := ClipSaved
		If StrLen(Path) > 80
		{
			SplitPath,Path,,PathDir
			Path1 := SubStr(Path,1,15)
			Path2 := SubStr(Path,RegExMatch(Path,"\\[^\\]*$")-Strlen(Path))
			Path := Path1 . "..." . SubStr(Path2,1,65) "..."
		}
		M := SubStr(OutVar,2,1)
		mPath := "&" . m . ">>" . Path
		If RegExMatch(Mark["ms"],m)
		{
			DelM := Mark[m]
			Menu,MarkMenu,Delete,%DelM%
			Menu,MarkMenu,Add,%mPath%,<AddMark>
			Mark["ms"] := Mark["ms"] . m
			Mark[m] := mPath
		}
		Else
		{
			Menu,MarkMenu,Add,%mPath%,<AddMark>
			Mark["ms"] := Mark["ms"] . m
			Mark[m] := mPath
		}
	}
}
<AddMark>:
	AddMark()
Return
AddMark()
{
	ThisMenuItem := SubStr(A_ThisMenuItem,5,StrLen(A_ThisMenuItem))
	If RegExMatch(ThisMenuItem,"i)\\\\桌面$")
	{
		Postmessage 1075, 2121, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\计算机$")
	{
		Postmessage 1075, 2122, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\所有控制面板项$")
	{
		Postmessage 1075, 2123, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\Fonts$")
	{
		Postmessage 1075, 2124, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\网络$")
	{
		Postmessage 1075, 2125, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\打印机$")
	{
		Postmessage 1075, 2126, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\回收站$")
	{
		Postmessage 1075, 2127, 0, , ahk_class TTOTAL_CMD
		Return
	}
	ControlSetText, %TCEdit%, cd %ThisMenuItem%, ahk_class TTOTAL_CMD
	ControlSend, %TCEdit%, {Enter}, ahk_class TTOTAL_CMD
	Return
}
; <ListMark> {{{1
; 显示标记
<ListMark>:
	ListMark()
Return
ListMark()
{
	If Not Mark["ms"]
		Return
	ControlGetFocus,TLB,ahk_class TTOTAL_CMD
	ControlGetPos,xn,yn,,,%TLB%,ahk_class TTOTAL_CMD
	Menu,MarkMenu,Show,%xn%,%yn%
}
; <CreateNewFile> {{{1
; 新建文件
<CreateNewFile>:
	CreateNewFile()
return
CreateNewFile()
{
	ControlGetFocus,TLB,ahk_class TTOTAL_CMD
	ControlGetPos,xn,yn,,,%TLB%,ahk_class TTOTAL_CMD
	Menu,FileTemp,Add
	Menu,FileTemp,DeleteAll
	Menu,FileTemp,Add ,0 新建文件,:CreateNewFile
	Menu,FileTemp,Icon,0 新建文件,%A_WinDir%\system32\Shell32.dll,-152
	Menu,FileTemp,Add ,1 文件夹,<cm_Mkdir>
	Menu,FileTemp,Icon,1 文件夹,%A_WinDir%\system32\Shell32.dll,4
	Menu,FileTemp,Add ,2 快捷方式,<cm_CreateShortcut>
	Menu,FileTemp,Icon,2 快捷方式,%A_WinDir%\system32\Shell32.dll,264
	Menu,FileTemp,Add ,3 添加到新模板,<AddToTempFiles>
	Menu,FileTemp,Icon,3 添加到新模板,%A_WinDir%\system32\Shell32.dll,-155
	FileTempMenuCheck()
	Menu,FileTemp,Show,%xn%,%yn%
}
; 检查文件模板功能
FileTempMenuCheck()
{
	Global TCPath
	Splitpath,TCPath,,TCDir
	Loop,%TCDir%\shellnew\*.*
	{
		If A_Index = 1
			Menu,FileTemp,Add
		ft := chr(64+A_Index) . " >> " . A_LoopFileName
		Menu,FileTemp,Add,%ft%,FileTempNew
		Ext := "." . A_LoopFileExt
		IconFile := RegGetNewFileIcon(Ext)
		IconFIle := RegExReplace(IconFile,"i)%systemroot%",A_WinDir)
		IconFilePath := RegExReplace(IconFile,",-?\d*","")
		IconFileIndex := RegExReplace(IconFile,".*,","")
		If Not FileExist(IconFilePath)
			Menu,FileTemp,Icon,%ft%,%A_WinDir%\system32\Shell32.dll,-152
		Else
			Menu,FileTemp,Icon,%ft%,%IconFilePath%,%IconFileIndex%
	}
}
; 添加到文件模板中
<AddToTempFiles>:
	AddToTempFiles()
return
AddToTempFiles()
{
	ClipSaved := ClipboardAll
	Clipboard :=
	GoSub,<cm_CopyFullNamesToClip>
	ClipWait,2
	If clipboard
		AddPath := clipboard
	Else
		Return
	clipboard := ClipSaved
	If FileExist(AddPath)
		Splitpath,AddPath,filename,,fileext,filenamenoext
	else
		Return
	Gui, Destroy
	Gui, Add, Text, Hidden, %AddPath%
	Gui, Add, Text, x12 y20 w50 h20 +Center, 模板源
	Gui, Add, Edit, x72 y20 w300 h20 Disabled, %FileName%
	Gui, Add, Text, x12 y50 w50 h20 +Center, 模板名
	Gui, Add, Edit, x72 y50 w300 h20 , %FileName%
	Gui, Add, Button, x162 y80 w90 h30 gAddTempOK default, 确认(&S)
	Gui, Add, Button, x282 y80 w90 h30 gNewFileClose , 取消(&C)
	Gui, Show, w400 h120, 添加模板
	If Fileext
	{
		Controlget,nf,hwnd,,edit2,A
		PostMessage,0x0B1,0,Strlen(filenamenoext),Edit2,A
	}
}
AddTempOK:
	AddTempOK()
return
AddTempOK()
{
	Global TCPath
	GuiControlGet,SrcPath,,Static1
	Splitpath,SrcPath,filename,,fileext,filenamenoext
	GuiControlGet,NewFileName,,Edit2
	SNDir := RegExReplace(TCPath,"[^\\]*$") . "ShellNew\"
	If Not FileExist(SNDir)
		FileCreateDir,%SNDir%
	NewFile := SNDir . NewFileName
	FileCopy,%SrcPath%,%NewFile%,1
	Gui,Destroy
}
; 新建文件模板
FileTempNew:
	NewFile(RegExReplace(A_ThisMenuItem,".\s>>\s",RegExReplace(TCPath,"\\[^\\]*$","\shellnew\")))
return
; 新建文件
NewFile:
	NewFile()
return
NewFile(File="")
{
	Global NewFile
	If Not File
		File := RegExReplace(NewFiles[A_ThisMenuItemPos],"(.*\[|\]$)","")
	If Not FileExist(File)
	{
		RegRead,ShellNewDir,HKEY_USERS,.default\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
		If Not ShellNewDir
			ShellNewDir := "C:\windows\Shellnew"
		File := ShellNewDir . "\" file
		If RegExMatch(SubStr(file,-7),"NullFile")
		{
			fileext := RegExReplace(NewFiles[A_ThisMenuItemPos],"(.*\(|\).*)")
			File := "New" . fileext
			FileName := "New" . fileext
			FileNamenoext := "New"
		}
	}
	Else
		Splitpath,file,filename,,fileext,filenamenoext
	Gui, Destroy
	Gui, Add, Text, x12 y20 w50 h20 +Center, 模板源
	Gui, Add, Edit, x72 y20 w300 h20 Disabled, %file%
	Gui, Add, Text, x12 y50 w50 h20 +Center, 新建文件
	Gui, Add, Edit, x72 y50 w300 h20 , %filename%
	Gui, Add, Button, x162 y80 w90 h30 gNewFileOk default, 确认(&S)
	Gui, Add, Button, x282 y80 w90 h30 gNewFileClose , 取消(&C)
	Gui, Show, w400 h120, 新建文件
	If Fileext
	{
		Controlget,nf,hwnd,,edit2,A
		PostMessage,0x0B1,0,Strlen(filenamenoext),Edit2,A
	}
	return
}
; 关闭新建文件窗口
NewFileClose:
	Gui,Destroy
return

; 确认新建文件
NewFileOK:
	NewFileOK()
return
NewFileOK()
{
	GuiControlGet,SrcPath,,Edit1
	GuiControlGet,NewFileName,,Edit2
	ClipSaved := ClipboardAll
	Clipboard :=
	GoSub,<cm_CopySrcPathToClip>
	ClipWait,2
	If clipboard
		DstPath := Clipboard
	Else
		Return
	clipboard := ClipSaved
		If RegExMatch(DstPath,"^\\\\计算机$")
		Return
	If RegExMatch(DstPath,"i)\\\\所有控制面板项$")
		Return
	If RegExMatch(DstPath,"i)\\\\Fonts$")
		Return
	If RegExMatch(DstPath,"i)\\\\网络$")
		Return
	If RegExMatch(DstPath,"i)\\\\打印机$")
		Return
	If RegExMatch(DstPath,"i)\\\\回收站$")
		Return
	If RegExmatch(DstPath,"^\\\\桌面$")
		DstPath := A_Desktop
	NewFile := DstPath . "\" . NewFileName
	If FileExist(NewFile)
	{
		MsgBox, 4, 新建文件, 新建文件已存在，是否覆盖？
		IfMsgBox No
			Return
	}
		FileCopy,%SrcPath%,%NewFile%,1
	Gui,Destroy
	WinActivate,AHK_CLASS TTOTAL_CMD
	ControlGetFocus,FocusCtrl,AHK_Class TTOTAL_CMD
	IF RegExMatch(FocusCtrl,TCListBox)
	{
		GoSub,<cm_RereadSource>
		ControlGet,Text,List,,%FocusCtrl%,AHK_CLASS TTOTAL_CMD
		Loop,Parse,Text,`n
		{
			If RegExMatch(A_LoopField,NewFileName)
			{
				Index := A_Index - 1
				Postmessage,0x19E,%Index%,1,%FocusCtrl%,AHK_CLASS TTOTAL_CMD
				Break
			}
		}
	}
}
;============================================================================
; ReadNewFile()
; 新建文件菜单
ReadNewFile()
{
	NewFiles[0] := 0
	SetBatchLines -1
	Loop,HKEY_CLASSES_ROOT ,,1,0
	{
		If RegExMatch(A_LoopRegName,"^\..*")
		{
			Reg := A_LoopRegName
			Loop,HKEY_CLASSES_ROOT,%Reg%,1,1
			{
				If RegExMatch(A_LoopRegName,"i)shellnew")
				{
					NewReg := A_LoopRegSubKey "\shellnew"
					If RegGetNewFilePath(NewReg)
					{
						NewFiles[0]++
						Index := NewFiles[0]
						NewFiles[Index] := RegGetNewFileDescribe(Reg) . "(" . Reg . ")[" . RegGetNewFilePath(NewReg) . "]"
					}
				}
			}
		}
	}
	LoopCount := NewFiles[0]
	Half := LoopCount/2
	Loop % LoopCount
	{
		If A_Index < %Half%
		{
			B_Index := NewFiles[0] - A_Index + 1
			C_Index := NewFiles[A_Index]
			NewFiles[A_Index] := NewFiles[B_Index]
			NewFiles[B_Index] := C_Index
		}
	}
	Menu,CreateNewFile,UseErrorLevel,On
	Loop % NewFiles[0]
	{
		File := RegExReplace(NewFiles[A_Index],"\(.*","")
		Exec := RegExReplace(NewFiles[A_Index],"(.*\(|\)\[.*)","")
		MenuFile := Chr(A_Index+64) . " >> " . File . "(" Exec . ")"
		Menu,CreateNewFile,Add,%MenuFile%,NewFile

		IconFile := RegGetNewFileIcon(Exec)
		IconFIle := RegExReplace(IconFile,"i)%systemroot%",A_WinDir)
		IconFilePath := RegExReplace(IconFile,",-?\d*","")
		If Not FileExist(IconFilePath)
			IconFilePath := ""
		IconFileIndex := RegExReplace(IconFile,".*,","")
		If Not RegExMatch(IconFileIndex,"^-?\d*$")
			IconFileIndex := ""
		If RegExMatch(Exec,"\.lnk")
		{
			IconFilePath := A_WinDir . "\system32\Shell32.dll"
			IconFileIndex := "264"
		}
		Menu,CreateNewFile,Icon,%MenuFile%,%IconFilePath%,%IconFileIndex%
	}
}
; 获取新建文件的源
; reg 为后缀
RegGetNewFilePath(reg)
{
	RegRead,GetRegPath,HKEY_CLASSES_ROOT,%Reg%,FileName
	IF Not ErrorLevel
		Return GetRegPath
	RegRead,GetRegPath,HKEY_CLASSES_ROOT,%Reg%,NullFile
	IF Not ErrorLevel
		Return "NullFile"
}
; RegGetNewFileType(reg)
; 获取新建文件类型名
; reg 为后缀
RegGetNewFileType(reg)
{
	RegRead,FileType,HKEY_CLASSES_ROOT,%Reg%
	If Not ErrorLevel
		Return FileType
}
; 获取文件描述
; reg 为后缀
RegGetNewFileDescribe(reg)
{
	FileType := RegGetNewFileType(reg)
	RegRead,FileDesc,HKEY_CLASSES_ROOT,%FileType%
	If Not ErrorLevel
		Return FileDesc
}
; 获取文件对应的图标
; reg 为后缀
RegGetNewFileIcon(reg)
{
	IconPath := RegGetNewFileType(reg) . "\DefaultIcon"
	RegRead,FileIcon,HKEY_CLASSES_ROOT,%IconPath%
	If Not ErrorLevel
		Return FileIcon
}
; <GoToParentEx> {{{1
; 返回到上层文件夹，可返回到我的电脑
<GoToParentEx>:
	IsRootDir()
	GoSub,<cm_GoToParent>
return
IsRootDir()
{
	ClipSaved := ClipboardAll
	clipboard :=
	GoSub,<cm_CopySrcPathToClip>
	ClipWait,1
	Path := Clipboard
	Clipboard := ClipSaved
	If RegExMatch(Path,"^.:\\$")
	{
		GoSub,<cm_OpenDrives>
		Path := "i)" . RegExReplace(Path,"\\","")
		ControlGetFocus,focus_control,AHK_CLASS TTOTAL_CMD
		ControlGet,outvar,list,,%focus_control%,AHK_CLASS TTOTAL_CMD
		Loop,Parse,Outvar,`n
		{
			If Not A_LoopField
				Break
			If RegExMatch(A_LoopField,Path)
			{
				Focus := A_Index - 1
				Break
			}
		}
		PostMessage, 0x19E, %Focus%, 1, %focus_control%, AHK_CLASS TTOTAL_CMD
	}
}
<AlwayOnTop>:
	AlwayOnTop()
Return
AlwayOnTop()
{
	WinGet,ExStyle,ExStyle,ahk_class TTOTAL_CMD
	If (ExStyle & 0x8)
   		WinSet,AlwaysOnTop,off,ahk_class TTOTAL_CMD
	else
   		WinSet,AlwaysOnTop,on,ahk_class TTOTAL_CMD
}

TConly:
;=======================================================
	Global TCPath
	TCPath := "e:\Program Files\totalcmd\TOTALCMD.EXE"
	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("<azHistory>","a-z历史导航")
	vim.Comment("<DownSelect>","向下选择")
	vim.Comment("<UpSelect>","向上选择")
	vim.Comment("<Mark>","标记功能")
	vim.Comment("<ForceDelete>","强制删除")
	vim.Comment("<ListMark>","显示标记")
	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.mode("normal","TQUICKSEARCH")
	vim.map("J","<Down>","TQUICKSEARCH")
	;;默认按键(VIM)
	vim.map("K","<Up>","TQUICKSEARCH")
    ;vim.map("<esc>","<Normal_Mode_TC>","TQUICKSEARCH")
	vim.mode("insert","TTOTAL_CMD")
    vim.map("<esc>","<Normal_Mode_TC>","TTOTAL_CMD")
	vim.map("<lwin>e","<ToggleTC>")

    vim.mode("normal","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","<cm_DirectoryHistory>","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("G","<LastLine>","TTOTAL_CMD")
	vim.map("ga","<cm_CloseAllTabs>","TTOTAL_CMD")
	vim.map("gg","<GoToLine>","TTOTAL_CMD")
	vim.map("gn","<cm_SwitchToNextTab>","TTOTAL_CMD")
	vim.map("gp","<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","<cm_50Percent>","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("zs","<TransParent>","TTOTAL_CMD")
	vim.map(".","<Repeat>","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()
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,%TCListBox%
		Return False
	Return True
}
<ExcSubOK>:
	Tooltip
return
; <Esc_TC> {{{1
<Normal_Mode_TC>:
	Send,{Esc}
    vim.Mode("normal","TTOTAL_CMD")
	;emptymem()
return
; <insert_TC> {{{1
<Insert_Mode_TC>:
    vim.Mode("insert","TTOTAL_CMD")
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
		}
	}
    ;settimer,AUTHTC,on
	;emptymem()
return
AUTHTC:
    AUTHTC()
return
AUTHTC()
{
    WinGetText, string,ahk_class TNASTYNAGSCREEN
    If Strlen(string)
    {
        RegExMatch(string,"\d",idx)
        ControlClick,TButton%idx%,ahk_class TNASTYNAGSCREEN,,,,NA
        ;msgbox % idx
        settimer,AUTHTC,off
    }
}
; <azHistory> {{{1
<azHistory>:
		azhistory()
Return
azhistory()
{
	GoSub,<cm_DirectoryHistory>
	Sleep, 200
	if WinExist("ahk_class #32768")
	{
		SendMessage,0x01E1 ;Get Menu Hwnd
		hmenu := ErrorLevel
		if hmenu!=0
		{
			If Not RegExMatch(GetMenuString(Hmenu,1),".*[\\|/]$")
				Return
			Menu,sh,UseErrorLevel
			Menu,sh,add
			Menu,sh,deleteall
			If ErrorLevel
				return
			a :=
			itemCount := DllCall("GetMenuItemCount", "Uint", hMenu, "Uint")
			Loop %itemCount%
			{
				;a := chr(A_Index+64) . ">>" .  GetMenuString(Hmenu,A_Index-1)
				a :=  GetMenuString(Hmenu,A_Index-1) A_Tab "[&"  chr(A_Index+64) "]"
				Menu,SH,add,%a%,azSelect
				If not Mod(A_Index,3)
					Menu,SH,add
			}
			Send {Esc}
			ControlGetFocus,TLB,ahk_class TTOTAL_CMD
			ControlGetPos,xn,yn,,,%TLB%,ahk_class TTOTAL_CMD
			Menu,SH,show,%xn%,%yn%
			Return
		}
	}
}
GetMenuString(hMenu, nPos)
{
      VarSetCapacity(lpString, 256)
      length := DllCall("GetMenuString"
         , "UInt", hMenu
         , "UInt", nPos
         , "Str", lpString
         , "Int", 255
         , "UInt", 0x0400)
   	  return lpString
}
azSelect:
	azSelect()
Return
azSelect()
{
	nPos := A_ThisMenuItem
	nPos := Asc(Substr(nPos,-1,1)) - 64
	Winactivate,ahk_class TTOTAL_CMD
	Postmessage,1075,572,0,,ahk_class TTOTAL_CMD
	Sleep,200
	if WinExist("ahk_class #32768")
	{
		Loop %nPos%
			SendInput {Down}
		Send {enter}
	}
}
; <DownSelect> {{{1
<DownSelect>:
	Send +{Down}
return
; <upSelect> {{{1
<upSelect>:
	Send +{Up}
return
; <WinMaxLeft> {{{1
<WinMaxLeft>:
	WinMaxLR(true)
Return
; <WinMaxRight> {{{1
<WinMaxRight>:
	WinMaxLR(false)
Return
WinMaxLR(lr)
{
	If lr
	{
		ControlGetPos,x,y,w,h,%TCPanel2%,ahk_class TTOTAL_CMD
		ControlGetPos,tm1x,tm1y,tm1W,tm1H,%TCPanel1%,ahk_class TTOTAL_CMD
		If (tm1w < tm1h) ; 判断纵向还是横向 Ture为竖 false为横
		{
			ControlMove,%TCPanel1%,x+w,,,,ahk_class TTOTAL_CMD
		}
		else
			ControlMove,%TCPanel1%,0,y+h,,,ahk_class TTOTAL_CMD
		ControlClick, %TCPanel1%,ahk_class TTOTAL_CMD
		WinActivate ahk_class TTOTAL_CMD
	}
	Else
	{
		ControlMove,%TCPanel1%,0,0,,,ahk_class TTOTAL_CMD
		ControlClick,%TCPanel1%,ahk_class TTOTAL_CMD
		WinActivate ahk_class TTOTAL_CMD
	}
}
; <GoLastTab> {{{1
<GoLastTab>:
	GoSub,<cm_SrcActivateTab1>
	GoSub,<cm_SwitchToPreviousTab>
return
; <CopyNameOnly> {{{1
<CopyNameOnly>:
		CopyNameOnly()
Return
CopyNameOnly()
{
	clipboard :=
	GoSub,<cm_CopyNamesToClip>
	ClipWait
	If Not RegExMatch(clipboard,"^\..*")
		clipboard := RegExReplace(RegExReplace(clipboard,"\\$"),"\.[^\.]*$")
}
; <ForceDelete>  {{{1
; 强制删除
<ForceDelete>:
	Send +{Delete}
return
; <GotoLine> {{{1
; 转到[count]行,缺省第一行
<GotoLine>:
	If Vim_HotKeyCount
		GotoLine(Vim_HotKeyCount)
	Else
		GotoLine(1)
return
; <LastLine> {{{1
; 转到[count]行, 最后一行
<LastLine>:
	If Vim_HotKeyCount
		GotoLine(Vim_HotKeyCount)
	Else
		GotoLine(0)
return
GotoLine(Index)
{
	Vim_HotKeyCount := 0
	ControlGetFocus,Ctrl,AHK_CLASS TTOTAL_CMD
	If Index
	{
		Index--
		ControlGet,text,List,,%ctrl%,AHK_CLASS TTOTAL_CMD
		Stringsplit,T,Text,`n
		Last := T0 - 1
		If Index > %Last%
			Index := Last
		Postmessage,0x19E,%Index%,1,%Ctrl%,AHK_CLASS TTOTAL_CMD
	}
	Else
	{
		ControlGet,text,List,,%ctrl%,AHK_CLASS TTOTAL_CMD
		Stringsplit,T,Text,`n
		Last := T0 - 1
		PostMessage, 0x19E,  %Last% , 1 , %CTRL%, AHK_CLASS TTOTAL_CMD
	}
}
; <Half>  {{{1
; 移动到窗口中间
<Half>:
		Half()
Return
Half()
{
	winget,tid,id,ahk_class TTOTAL_CMD
	controlgetfocus,ctrl,ahk_id %tid%
	controlget,cid,hwnd,,%ctrl%,ahk_id %tid%
	controlgetpos,x1,y1,w1,h1,THeaderClick2,ahk_id %tid%
	controlgetpos,x,y,w,h,%ctrl%,ahk_id %tid%
	SendMessage,0x01A1,1,0,,ahk_id %cid%
	Hight := ErrorLevel
	SendMessage,0x018E,0,0,,ahk_id %cid%
	Top := ErrorLevel
	HalfLine := Ceil( ((h-h1)/Hight)/2 ) + Top
	PostMessage, 0x19E, %HalfLine%, 1, , AHK_id %cid%
}
; <Mark> {{{1
; 标记功能
<Mark>:
	Mark()
Return
Mark()
{
	vim.mode("insert")
	GoSub,<cm_FocusCmdLine>
	ControlGet,EditId,Hwnd,,AHK_CLASS TTOTAL_CMD
	ControlSetText,%TCEdit%,m,AHK_CLASS TTOTAL_CMD
	Postmessage,0xB1,2,2,%TCEdit%,AHK_CLASS TTOTAL_CMD
	SetTimer,<MarkTimer>,100
}
<MarkTimer>:
	MarkTimer()
Return
MarkTimer()
{
	ControlGetFocus,ThisControl,AHK_CLASS TTOTAL_CMD
	ControlGetText,OutVar,%TCEdit%,AHK_CLASS TTOTAL_CMD
	Match_TCEdit := "i)^" . TCEdit . "$"
	If Not RegExMatch(ThisControl,Match_TCEdit) OR Not RegExMatch(Outvar,"i)^m.?")
	{
		vim.mode("normal")
		Settimer,<MarkTimer>,Off
		Return
	}
	If RegExMatch(OutVar,"i)^m.+")
	{
		vim.mode("normal")
		SetTimer,<MarkTimer>,off
		ControlSetText,%TCEdit%,,AHK_CLASS TTOTAL_CMD
		ControlSend,%TCEdit%,{Esc},AHK_CLASS TTOTAL_CMD
		ClipSaved := ClipboardAll
		Clipboard :=
		Postmessage 1075, 2029, 0, , ahk_class TTOTAL_CMD
		ClipWait
		Path := Clipboard
		Clipboard := ClipSaved
		If StrLen(Path) > 80
		{
			SplitPath,Path,,PathDir
			Path1 := SubStr(Path,1,15)
			Path2 := SubStr(Path,RegExMatch(Path,"\\[^\\]*$")-Strlen(Path))
			Path := Path1 . "..." . SubStr(Path2,1,65) "..."
		}
		M := SubStr(OutVar,2,1)
		mPath := "&" . m . ">>" . Path
		If RegExMatch(Mark["ms"],m)
		{
			DelM := Mark[m]
			Menu,MarkMenu,Delete,%DelM%
			Menu,MarkMenu,Add,%mPath%,<AddMark>
			Mark["ms"] := Mark["ms"] . m
			Mark[m] := mPath
		}
		Else
		{
			Menu,MarkMenu,Add,%mPath%,<AddMark>
			Mark["ms"] := Mark["ms"] . m
			Mark[m] := mPath
		}
	}
}
<AddMark>:
	AddMark()
Return
AddMark()
{
	ThisMenuItem := SubStr(A_ThisMenuItem,5,StrLen(A_ThisMenuItem))
	If RegExMatch(ThisMenuItem,"i)\\\\桌面$")
	{
		Postmessage 1075, 2121, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\计算机$")
	{
		Postmessage 1075, 2122, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\所有控制面板项$")
	{
		Postmessage 1075, 2123, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\Fonts$")
	{
		Postmessage 1075, 2124, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\网络$")
	{
		Postmessage 1075, 2125, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\打印机$")
	{
		Postmessage 1075, 2126, 0, , ahk_class TTOTAL_CMD
		Return
	}
	If RegExMatch(ThisMenuItem,"i)\\\\回收站$")
	{
		Postmessage 1075, 2127, 0, , ahk_class TTOTAL_CMD
		Return
	}
	ControlSetText, %TCEdit%, cd %ThisMenuItem%, ahk_class TTOTAL_CMD
	ControlSend, %TCEdit%, {Enter}, ahk_class TTOTAL_CMD
	Return
}
; <ListMark> {{{1
; 显示标记
<ListMark>:
	ListMark()
Return
ListMark()
{
	If Not Mark["ms"]
		Return
	ControlGetFocus,TLB,ahk_class TTOTAL_CMD
	ControlGetPos,xn,yn,,,%TLB%,ahk_class TTOTAL_CMD
	Menu,MarkMenu,Show,%xn%,%yn%
}
; <CreateNewFile> {{{1
; 新建文件
<CreateNewFile>:
	CreateNewFile()
return
CreateNewFile()
{
	ControlGetFocus,TLB,ahk_class TTOTAL_CMD
	ControlGetPos,xn,yn,,,%TLB%,ahk_class TTOTAL_CMD
	Menu,FileTemp,Add
	Menu,FileTemp,DeleteAll
	Menu,FileTemp,Add ,0 新建文件,:CreateNewFile
	Menu,FileTemp,Icon,0 新建文件,%A_WinDir%\system32\Shell32.dll,-152
	Menu,FileTemp,Add ,1 文件夹,<cm_Mkdir>
	Menu,FileTemp,Icon,1 文件夹,%A_WinDir%\system32\Shell32.dll,4
	Menu,FileTemp,Add ,2 快捷方式,<cm_CreateShortcut>
	Menu,FileTemp,Icon,2 快捷方式,%A_WinDir%\system32\Shell32.dll,264
	Menu,FileTemp,Add ,3 添加到新模板,<AddToTempFiles>
	Menu,FileTemp,Icon,3 添加到新模板,%A_WinDir%\system32\Shell32.dll,-155
	FileTempMenuCheck()
	Menu,FileTemp,Show,%xn%,%yn%
}
; 检查文件模板功能
FileTempMenuCheck()
{
	Global TCPath
	Splitpath,TCPath,,TCDir
	Loop,%TCDir%\shellnew\*.*
	{
		If A_Index = 1
			Menu,FileTemp,Add
		ft := chr(64+A_Index) . " >> " . A_LoopFileName
		Menu,FileTemp,Add,%ft%,FileTempNew
		Ext := "." . A_LoopFileExt
		IconFile := RegGetNewFileIcon(Ext)
		IconFIle := RegExReplace(IconFile,"i)%systemroot%",A_WinDir)
		IconFilePath := RegExReplace(IconFile,",-?\d*","")
		IconFileIndex := RegExReplace(IconFile,".*,","")
		If Not FileExist(IconFilePath)
			Menu,FileTemp,Icon,%ft%,%A_WinDir%\system32\Shell32.dll,-152
		Else
			Menu,FileTemp,Icon,%ft%,%IconFilePath%,%IconFileIndex%
	}
}
; 添加到文件模板中
<AddToTempFiles>:
	AddToTempFiles()
return
AddToTempFiles()
{
	ClipSaved := ClipboardAll
	Clipboard :=
	GoSub,<cm_CopyFullNamesToClip>
	ClipWait,2
	If clipboard
		AddPath := clipboard
	Else
		Return
	clipboard := ClipSaved
	If FileExist(AddPath)
		Splitpath,AddPath,filename,,fileext,filenamenoext
	else
		Return
	Gui, Destroy
	Gui, Add, Text, Hidden, %AddPath%
	Gui, Add, Text, x12 y20 w50 h20 +Center, 模板源
	Gui, Add, Edit, x72 y20 w300 h20 Disabled, %FileName%
	Gui, Add, Text, x12 y50 w50 h20 +Center, 模板名
	Gui, Add, Edit, x72 y50 w300 h20 , %FileName%
	Gui, Add, Button, x162 y80 w90 h30 gAddTempOK default, 确认(&S)
	Gui, Add, Button, x282 y80 w90 h30 gNewFileClose , 取消(&C)
	Gui, Show, w400 h120, 添加模板
	If Fileext
	{
		Controlget,nf,hwnd,,edit2,A
		PostMessage,0x0B1,0,Strlen(filenamenoext),Edit2,A
	}
}
AddTempOK:
	AddTempOK()
return
AddTempOK()
{
	Global TCPath
	GuiControlGet,SrcPath,,Static1
	Splitpath,SrcPath,filename,,fileext,filenamenoext
	GuiControlGet,NewFileName,,Edit2
	SNDir := RegExReplace(TCPath,"[^\\]*$") . "ShellNew\"
	If Not FileExist(SNDir)
		FileCreateDir,%SNDir%
	NewFile := SNDir . NewFileName
	FileCopy,%SrcPath%,%NewFile%,1
	Gui,Destroy
}
; 新建文件模板
FileTempNew:
	NewFile(RegExReplace(A_ThisMenuItem,".\s>>\s",RegExReplace(TCPath,"\\[^\\]*$","\shellnew\")))
return
; 新建文件
NewFile:
	NewFile()
return
NewFile(File="")
{
	Global NewFile
	If Not File
		File := RegExReplace(NewFiles[A_ThisMenuItemPos],"(.*\[|\]$)","")
	If Not FileExist(File)
	{
		RegRead,ShellNewDir,HKEY_USERS,.default\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
		If Not ShellNewDir
			ShellNewDir := "C:\windows\Shellnew"
		File := ShellNewDir . "\" file
		If RegExMatch(SubStr(file,-7),"NullFile")
		{
			fileext := RegExReplace(NewFiles[A_ThisMenuItemPos],"(.*\(|\).*)")
			File := "New" . fileext
			FileName := "New" . fileext
			FileNamenoext := "New"
		}
	}
	Else
		Splitpath,file,filename,,fileext,filenamenoext
	Gui, Destroy
	Gui, Add, Text, x12 y20 w50 h20 +Center, 模板源
	Gui, Add, Edit, x72 y20 w300 h20 Disabled, %file%
	Gui, Add, Text, x12 y50 w50 h20 +Center, 新建文件
	Gui, Add, Edit, x72 y50 w300 h20 , %filename%
	Gui, Add, Button, x162 y80 w90 h30 gNewFileOk default, 确认(&S)
	Gui, Add, Button, x282 y80 w90 h30 gNewFileClose , 取消(&C)
	Gui, Show, w400 h120, 新建文件
	If Fileext
	{
		Controlget,nf,hwnd,,edit2,A
		PostMessage,0x0B1,0,Strlen(filenamenoext),Edit2,A
	}
	return
}
; 关闭新建文件窗口
NewFileClose:
	Gui,Destroy
return

; 确认新建文件
NewFileOK:
	NewFileOK()
return
NewFileOK()
{
	GuiControlGet,SrcPath,,Edit1
	GuiControlGet,NewFileName,,Edit2
	ClipSaved := ClipboardAll
	Clipboard :=
	GoSub,<cm_CopySrcPathToClip>
	ClipWait,2
	If clipboard
		DstPath := Clipboard
	Else
		Return
	clipboard := ClipSaved
		If RegExMatch(DstPath,"^\\\\计算机$")
		Return
	If RegExMatch(DstPath,"i)\\\\所有控制面板项$")
		Return
	If RegExMatch(DstPath,"i)\\\\Fonts$")
		Return
	If RegExMatch(DstPath,"i)\\\\网络$")
		Return
	If RegExMatch(DstPath,"i)\\\\打印机$")
		Return
	If RegExMatch(DstPath,"i)\\\\回收站$")
		Return
	If RegExmatch(DstPath,"^\\\\桌面$")
		DstPath := A_Desktop
	NewFile := DstPath . "\" . NewFileName
	If FileExist(NewFile)
	{
		MsgBox, 4, 新建文件, 新建文件已存在，是否覆盖？
		IfMsgBox No
			Return
	}
		FileCopy,%SrcPath%,%NewFile%,1
	Gui,Destroy
	WinActivate,AHK_CLASS TTOTAL_CMD
	ControlGetFocus,FocusCtrl,AHK_Class TTOTAL_CMD
	IF RegExMatch(FocusCtrl,TCListBox)
	{
		GoSub,<cm_RereadSource>
		ControlGet,Text,List,,%FocusCtrl%,AHK_CLASS TTOTAL_CMD
		Loop,Parse,Text,`n
		{
			If RegExMatch(A_LoopField,NewFileName)
			{
				Index := A_Index - 1
				Postmessage,0x19E,%Index%,1,%FocusCtrl%,AHK_CLASS TTOTAL_CMD
				Break
			}
		}
	}
}
;============================================================================
; ReadNewFile()
; 新建文件菜单
ReadNewFile()
{
	NewFiles[0] := 0
	SetBatchLines -1
	Loop,HKEY_CLASSES_ROOT ,,1,0
	{
		If RegExMatch(A_LoopRegName,"^\..*")
		{
			Reg := A_LoopRegName
			Loop,HKEY_CLASSES_ROOT,%Reg%,1,1
			{
				If RegExMatch(A_LoopRegName,"i)shellnew")
				{
					NewReg := A_LoopRegSubKey "\shellnew"
					If RegGetNewFilePath(NewReg)
					{
						NewFiles[0]++
						Index := NewFiles[0]
						NewFiles[Index] := RegGetNewFileDescribe(Reg) . "(" . Reg . ")[" . RegGetNewFilePath(NewReg) . "]"
					}
				}
			}
		}
	}
	LoopCount := NewFiles[0]
	Half := LoopCount/2
	Loop % LoopCount
	{
		If A_Index < %Half%
		{
			B_Index := NewFiles[0] - A_Index + 1
			C_Index := NewFiles[A_Index]
			NewFiles[A_Index] := NewFiles[B_Index]
			NewFiles[B_Index] := C_Index
		}
	}
	Menu,CreateNewFile,UseErrorLevel,On
	Loop % NewFiles[0]
	{
		File := RegExReplace(NewFiles[A_Index],"\(.*","")
		Exec := RegExReplace(NewFiles[A_Index],"(.*\(|\)\[.*)","")
		MenuFile := Chr(A_Index+64) . " >> " . File . "(" Exec . ")"
		Menu,CreateNewFile,Add,%MenuFile%,NewFile

		IconFile := RegGetNewFileIcon(Exec)
		IconFIle := RegExReplace(IconFile,"i)%systemroot%",A_WinDir)
		IconFilePath := RegExReplace(IconFile,",-?\d*","")
		If Not FileExist(IconFilePath)
			IconFilePath := ""
		IconFileIndex := RegExReplace(IconFile,".*,","")
		If Not RegExMatch(IconFileIndex,"^-?\d*$")
			IconFileIndex := ""
		If RegExMatch(Exec,"\.lnk")
		{
			IconFilePath := A_WinDir . "\system32\Shell32.dll"
			IconFileIndex := "264"
		}
		Menu,CreateNewFile,Icon,%MenuFile%,%IconFilePath%,%IconFileIndex%
	}
}
; 获取新建文件的源
; reg 为后缀
RegGetNewFilePath(reg)
{
	RegRead,GetRegPath,HKEY_CLASSES_ROOT,%Reg%,FileName
	IF Not ErrorLevel
		Return GetRegPath
	RegRead,GetRegPath,HKEY_CLASSES_ROOT,%Reg%,NullFile
	IF Not ErrorLevel
		Return "NullFile"
}
; RegGetNewFileType(reg)
; 获取新建文件类型名
; reg 为后缀
RegGetNewFileType(reg)
{
	RegRead,FileType,HKEY_CLASSES_ROOT,%Reg%
	If Not ErrorLevel
		Return FileType
}
; 获取文件描述
; reg 为后缀
RegGetNewFileDescribe(reg)
{
	FileType := RegGetNewFileType(reg)
	RegRead,FileDesc,HKEY_CLASSES_ROOT,%FileType%
	If Not ErrorLevel
		Return FileDesc
}
; 获取文件对应的图标
; reg 为后缀
RegGetNewFileIcon(reg)
{
	IconPath := RegGetNewFileType(reg) . "\DefaultIcon"
	RegRead,FileIcon,HKEY_CLASSES_ROOT,%IconPath%
	If Not ErrorLevel
		Return FileIcon
}
; <GoToParentEx> {{{1
; 返回到上层文件夹，可返回到我的电脑
<GoToParentEx>:
	IsRootDir()
	GoSub,<cm_GoToParent>
return
IsRootDir()
{
	ClipSaved := ClipboardAll
	clipboard :=
	GoSub,<cm_CopySrcPathToClip>
	ClipWait,1
	Path := Clipboard
	Clipboard := ClipSaved
	If RegExMatch(Path,"^.:\\$")
	{
		GoSub,<cm_OpenDrives>
		Path := "i)" . RegExReplace(Path,"\\","")
		ControlGetFocus,focus_control,AHK_CLASS TTOTAL_CMD
		ControlGet,outvar,list,,%focus_control%,AHK_CLASS TTOTAL_CMD
		Loop,Parse,Outvar,`n
		{
			If Not A_LoopField
				Break
			If RegExMatch(A_LoopField,Path)
			{
				Focus := A_Index - 1
				Break
			}
		}
		PostMessage, 0x19E, %Focus%, 1, %focus_control%, AHK_CLASS TTOTAL_CMD
	}
}
<AlwayOnTop>:
	AlwayOnTop()
Return
AlwayOnTop()
{
	WinGet,ExStyle,ExStyle,ahk_class TTOTAL_CMD
	If (ExStyle & 0x8)
   		WinSet,AlwaysOnTop,off,ahk_class TTOTAL_CMD
	else
   		WinSet,AlwaysOnTop,on,ahk_class TTOTAL_CMD
}


Remove useless codescodes

Remove useless codescodes

#NoTrayIcon
#NoEnv

; Read ini file {{{1
ini_file = %A_ScriptDir%\etc\wsl-terminal.conf
IniRead, title, %ini_file%, config, title, "        "
IniRead, shell, %ini_file%, config, shell, "bash"
IniRead, use_tmux, %ini_file%, config, use_tmux, 0
IniRead, mintty_options, %ini_file%, config, mintty_options,
IniRead, icon, %ini_file%, config, icon,
IniRead, distro_guid, %ini_file%, config, distro_guid,
IniRead, keep_wsl_running, %ini_file%, config, keep_wsl_running, 0

if (mintty_options == "ERROR") {
    mintty_options =
}

; Prepare mintty_base and wslbridge_base {{{1
icon_path = %A_ScriptFullPath%
if (icon != "" && FileExist(icon)) {
    icon_path = %icon%
}

distro_option := ""
if (distro_guid != "ERROR") {
    distro_option = --distro-guid %distro_guid%
}

mintty_path = "%A_ScriptDir%\bin\mintty"
mintty_base = %mintty_path% --wsl --rootfs=// --configdir "%A_ScriptDir%\etc" -i "%icon_path%"
wslbridge_base = -e /bin/wslbridge %distro_option% -e SHELL="%shell%" -e LANG

; Run as run-wsl-file or any editor {{{1
SplitPath, A_ScriptName, , , , exe_name
if (exe_name == "run-wsl-file") {
    arg = %1%

    if (arg == "") {
        MsgBox, Open .sh/.py/.pl/... with %exe_name%.exe to run it in WSL.
        ExitApp
    }

    SplitPath, arg, filename, dir
    SetWorkingDir, %dir%

    Run, %mintty_base% %mintty_options% -t "%arg%" %wslbridge_base% -t ./"%filename%"
    ExitApp
} else if (exe_name != "open-wsl" && exe_name != "cmd") {
    ; editor
    argc = %0%
    filepath := ""
    filename := ""
    options := ""

    if (argc > 0) {
        filepath := %argc%

        Loop, % argc - 1 {
            options .= " " %A_Index%
        }

        SplitPath, filepath, filename, dir
        SetWorkingDir, %dir%

        if (InStr(filename, " ")) {
            filename = "%filename%"
        }
    }

    Run, %mintty_base% %mintty_options% -t "%filepath%" %wslbridge_base% -t "%exe_name%" %options% %filename%

    Loop, 5 {
        WinActivate, %filepath%
        if (WinActive(filepath)) {
            break
        }

        Sleep, 50
    }

    ExitApp
}

; Parse arguments {{{1
argc = %0%
args := []
Loop, %argc% {
    args.Insert(%A_Index%)
}

activate_window := False
change_directory := ""
distro := ""
login_shell := False
wslbridge_options := ""
user_command := ""

i := 0
while (i++ < argc) {
    c := args[i]
    if (c == "-a") {
        activate_window := True
    } else if (c == "-C") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require directory arg.
            ExitApp, 1
        }

        change_directory := args[i]
    } else if (c == "-W") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require directory arg.
            ExitApp, 1
        }

        SetWorkingDir, % args[i]
    } else if (c == "-l") {
        login_shell := True
    } else if (c == "-d") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require distro name arg.
            ExitApp, 1
        }

        distro := args[i]
    } else if (c == "-b") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require additional wslbridge options arg.
            ExitApp, 1
        }

        wslbridge_options := args[i]
    } else if (c == "-B") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require additional mintty options arg.
            ExitApp, 1
        }

        mintty_options .= " " args[i]
    } else if (c == "-c") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require command arg.
            ExitApp, 1
        }

        user_command := args[i]
    } else if (c == "-e") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require command arg.
            ExitApp, 1
        }

        user_command := shell " -c """ args[i]
        while (++i <= argc) {
            user_command .= " " args[i]
        }
        user_command .= """"
        StringReplace, user_command, user_command, `", `\`", All
    } else if (c == "-h") {
        help =
        (
        Usage: open-wsl [OPTION]...
          -a: activate an existing wsl-terminal window.
              if use_tmux=1, attach the running tmux session.
          -l: start terminal in your home directory (doesn't work with tmux).
          -c "command": run command (e.g. -c "echo a b; echo c; cat").
          -e commands: run commands (e.g. -e echo a b; echo c; cat).
          -C dir: change directory to a WSL dir (e.g. /home/username).
          -W dir: change directory to a Windows dir (e.g. c:\Users\username).
          -d distro: switch distros.
          -b "options": pass additional options to wslbridge.
          -B "options": pass additional options to mintty.
          -h: show help.
        )
        MsgBox, %help%
        ExitApp
    }
}

if (user_command != "") {
    if (change_directory != "") {
        wslbridge_options = %wslbridge_options% -C "%change_directory%"
    }

    Run, %mintty_base% %mintty_options% -t "%user_command%" %wslbridge_base% %wslbridge_options% -t %shell% -c "%user_command%"
    ExitApp
}

; Find bash.exe {{{1
bash_exe = %A_WinDir%\sysnative\bash.exe
if (!FileExist(bash_exe)) {
    bash_exe = %A_WinDir%\system32\bash.exe
} if (!FileExist(bash_exe)) {
    MsgBox, 0x10, , WSL(Windows Subsystem for Linux) must be installed.
    ExitApp, 1
}

; Switch distro {{{1
if (distro != "") {
    Run, % StrReplace(bash_exe, "bash.exe", "wslconfig.exe") " /s " distro
}

; Build command line {{{1
cmd =
opts = %wslbridge_options% -t

if (activate_window && WinExist(title)) {
} else if (!use_tmux) {
    if (login_shell) {
        cmd = %shell% -l
        if (change_directory == "") {
            change_directory = ~
        }
    } else {
        cmd = %shell%
    }
} else {
    if (WinExist(title)) {
        Run, "%bash_exe%" -c 'tmux new-window -c "$PWD"', , Hide
    } else {
        cmd = %shell%
        opts = %opts% -e USE_TMUX=1

        if (activate_window) {
            opts = %opts% -e ATTACH_ONLY=1
        }
    }
}

if (change_directory != "") {
    opts = %opts% -C "%change_directory%"
}

if (cmd != "") {
    lnk_args = %mintty_base% %mintty_options% -t "%title%" %wslbridge_base% %opts% %cmd%
    lnk_args := StrReplace(lnk_args, mintty_path)

    FileCreateShortcut, %A_ScriptDir%\bin\mintty.exe, %A_ScriptDir%\wsl-terminal.lnk, %A_WorkingDir%, %lnk_args%, wsl-terminal temp shortcut, %icon_path%
    Run, %A_ScriptDir%\wsl-terminal.lnk

    ;Run, %mintty_base% %mintty_options% -t "%title%" %wslbridge_base% %opts% %cmd%
}

; Activate window {{{1

if (activate_window || use_tmux) {
    Loop, 5 {
        WinActivate, %title%
        if (WinActive(title)) {
            break
        }

        Sleep, 50
    }
}

if (keep_wsl_running) {
    Process, Exist, sleep

    if (ErrorLevel == 0) {
        Run, "%bash_exe%" -c 'exec sleep 10000000d', , Hide
    }
}

#NoTrayIcon
#NoEnv

; Read ini file {{{1
ini_file = %A_ScriptDir%\etc\wsl-terminal.conf
IniRead, title, %ini_file%, config, title, "        "
IniRead, shell, %ini_file%, config, shell, "bash"
IniRead, use_cbwin, %ini_file%, config, use_cbwin, 0
IniRead, use_tmux, %ini_file%, config, use_tmux, 0
IniRead, mintty_options, %ini_file%, config, mintty_options,
IniRead, icon, %ini_file%, config, icon,
IniRead, distro_guid, %ini_file%, config, distro_guid,
IniRead, keep_wsl_running, %ini_file%, config, keep_wsl_running, 0

if (mintty_options == "ERROR") {
    mintty_options =
}

; Prepare mintty_base and wslbridge_base {{{1
icon_path = %A_ScriptFullPath%
if (icon != "" && FileExist(icon)) {
    icon_path = %icon%
}

distro_option := ""
if (distro_guid != "ERROR") {
    distro_option = --distro-guid %distro_guid%
}

mintty_path = "%A_ScriptDir%\bin\mintty"
mintty_base = %mintty_path% --wsl --rootfs=// --configdir "%A_ScriptDir%\etc" -i "%icon_path%"
wslbridge_base = -e /bin/wslbridge %distro_option% -e SHELL="%shell%" -e LANG

; Run as run-wsl-file or any editor {{{1
SplitPath, A_ScriptName, , , , exe_name
if (exe_name == "run-wsl-file") {
    arg = %1%

    if (arg == "") {
        MsgBox, Open .sh/.py/.pl/... with %exe_name%.exe to run it in WSL.
        ExitApp
    }

    SplitPath, arg, filename, dir
    SetWorkingDir, %dir%

    Run, %mintty_base% %mintty_options% -t "%arg%" %wslbridge_base% -t ./"%filename%"
    ExitApp
} else if (exe_name != "open-wsl" && exe_name != "cmd") {
    ; editor
    argc = %0%
    filepath := ""
    filename := ""
    options := ""

    if (argc > 0) {
        filepath := %argc%

        Loop, % argc - 1 {
            options .= " " %A_Index%
        }

        SplitPath, filepath, filename, dir
        SetWorkingDir, %dir%

        if (InStr(filename, " ")) {
            filename = "%filename%"
        }
    }

    Run, %mintty_base% %mintty_options% -t "%filepath%" %wslbridge_base% -t "%exe_name%" %options% %filename%

    Loop, 5 {
        WinActivate, %filepath%
        if (WinActive(filepath)) {
            break
        }

        Sleep, 50
    }

    ExitApp
}

; Parse arguments {{{1
argc = %0%
args := []
Loop, %argc% {
    args.Insert(%A_Index%)
}

activate_window := False
change_directory := ""
distro := ""
login_shell := False
wslbridge_options := ""
user_command := ""

i := 0
while (i++ < argc) {
    c := args[i]
    if (c == "-a") {
        activate_window := True
    } else if (c == "-C") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require directory arg.
            ExitApp, 1
        }

        change_directory := args[i]
    } else if (c == "-W") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require directory arg.
            ExitApp, 1
        }

        SetWorkingDir, % args[i]
    } else if (c == "-l") {
        login_shell := True
    } else if (c == "-d") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require distro name arg.
            ExitApp, 1
        }

        distro := args[i]
    } else if (c == "-b") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require additional wslbridge options arg.
            ExitApp, 1
        }

        wslbridge_options := args[i]
    } else if (c == "-B") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require additional mintty options arg.
            ExitApp, 1
        }

        mintty_options .= " " args[i]
    } else if (c == "-c") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require command arg.
            ExitApp, 1
        }

        user_command := args[i]
    } else if (c == "-e") {
        if (argc < ++i) {
            MsgBox, 0x10, , Require command arg.
            ExitApp, 1
        }

        user_command := shell " -c """ args[i]
        while (++i <= argc) {
            user_command .= " " args[i]
        }
        user_command .= """"
        StringReplace, user_command, user_command, `", `\`", All
    } else if (c == "-h") {
        help =
        (
        Usage: open-wsl [OPTION]...
          -a: activate an existing wsl-terminal window.
              if use_tmux=1, attach the running tmux session.
          -l: start terminal in your home directory (doesn't work with tmux).
          -c "command": run command (e.g. -c "echo a b; echo c; cat").
          -e commands: run commands (e.g. -e echo a b; echo c; cat).
          -C dir: change directory to a WSL dir (e.g. /home/username).
          -W dir: change directory to a Windows dir (e.g. c:\Users\username).
          -d distro: switch distros.
          -b "options": pass additional options to wslbridge.
          -B "options": pass additional options to mintty.
          -h: show help.
        )
        MsgBox, %help%
        ExitApp
    }
}

if (user_command != "") {
    if (change_directory != "") {
        wslbridge_options = %wslbridge_options% -C "%change_directory%"
    }

    Run, %mintty_base% %mintty_options% -t "%user_command%" %wslbridge_base% %wslbridge_options% -t %shell% -c "%user_command%"
    ExitApp
}

; Find bash.exe {{{1
bash_exe = %A_WinDir%\sysnative\bash.exe
if (!FileExist(bash_exe)) {
    bash_exe = %A_WinDir%\system32\bash.exe
} if (!FileExist(bash_exe)) {
    MsgBox, 0x10, , WSL(Windows Subsystem for Linux) must be installed.
    ExitApp, 1
}

; Switch distro {{{1
if (distro != "") {
    Run, % StrReplace(bash_exe, "bash.exe", "wslconfig.exe") " /s " distro
}

; Build command line {{{1
cmd =
opts = %wslbridge_options% -t

if (activate_window && WinExist(title)) {
} else if (!use_tmux) {
    if (login_shell) {
        cmd = %shell% -l
        if (change_directory == "") {
            change_directory = ~
        }
    } else {
        cmd = %shell%
    }
} else {
    if (WinExist(title)) {
        Run, "%bash_exe%" -c 'tmux new-window -c "$PWD"', , Hide
    } else {
        cmd = %shell%
        opts = %opts% -e USE_TMUX=1

        if (activate_window) {
            opts = %opts% -e ATTACH_ONLY=1
        }
    }
}

if (change_directory != "") {
    opts = %opts% -C "%change_directory%"
}

if (cmd != "") {
    lnk_args = %mintty_base% %mintty_options% -t "%title%" %wslbridge_base% %opts% %cmd%
    lnk_args := StrReplace(lnk_args, mintty_path)

    FileCreateShortcut, %A_ScriptDir%\bin\mintty.exe, %A_ScriptDir%\wsl-terminal.lnk, %A_WorkingDir%, %lnk_args%, wsl-terminal temp shortcut, %icon_path%
    Run, %A_ScriptDir%\wsl-terminal.lnk

    ;Run, %mintty_base% %mintty_options% -t "%title%" %wslbridge_base% %opts% %cmd%
}

; Activate window {{{1

if (activate_window || use_tmux) {
    Loop, 5 {
        WinActivate, %title%
        if (WinActive(title)) {
            break
        }

        Sleep, 50
    }
}

if (keep_wsl_running) {
    Process, Exist, sleep

    if (ErrorLevel == 0) {
        Run, "%bash_exe%" -c 'exec sleep 10000000d', , Hide
    }
}


Add left hand keys and numbers

Add left hand keys and numbers

; Using Keyboard Numpad as a Mouse -- by deguix
; http://www.autohotkey.com

;START OF CONFIG SECTION

#SingleInstance force
#MaxHotkeysPerInterval 500

; Using the keyboard hook to implement the Numpad hotkeys prevents
; them from interfering with the generation of ANSI characters such
; as .  This is because AutoHotkey generates such characters
; by holding down ALT and sending a series of Numpad keystrokes.
; Hook hotkeys are smart enough to ignore such keystrokes.
#UseHook

MouseSpeed = 1
MouseAccelerationSpeed = 1
MouseMaxSpeed = 5

;Mouse wheel speed is also set on Control Panel. As that
;will affect the normal mouse behavior, the real speed of
;these three below are times the normal mouse wheel speed.
MouseWheelSpeed = 1
MouseWheelAccelerationSpeed = 1
MouseWheelMaxSpeed = 5

;END OF CONFIG SECTION

;This is needed or key presses would faulty send their natural
;actions. Like NumPadDiv would send sometimes "/" to the
;screen.
#InstallKeybdHook

Temp = 0
Temp2 = 0

MouseCurrentAccelerationSpeed = 0
MouseCurrentSpeed = %MouseSpeed%

MouseWheelCurrentAccelerationSpeed = 0
MouseWheelCurrentSpeed = %MouseSpeed%

SetKeyDelay, -1
SetMouseDelay, -1

; Left hand
Hotkey, CapsLock & W, MouseLeftUp
Hotkey, CapsLock & E, MouseUp
Hotkey, CapsLock & R, MouseRightUp
Hotkey, CapsLock & S, MouseLeft
Hotkey, CapsLock & D, MouseDown
Hotkey, CapsLock & F, MouseRight
Hotkey, CapsLock & X, MouseLeftDown
Hotkey, CapsLock & C, MouseDown
Hotkey, CapsLock & V, MouseRightDown

; Right hand
Hotkey, CapsLock & U, MouseLeftUp
Hotkey, CapsLock & I, MouseUp
Hotkey, CapsLock & O, MouseRightUp
Hotkey, CapsLock & J, MouseLeft
Hotkey, CapsLock & K, MouseDown
Hotkey, CapsLock & L, MouseRight
Hotkey, CapsLock & M, MouseLeftDown
Hotkey, CapsLock & `, , MouseDown
Hotkey, CapsLock & `. , MouseRightDown

; Numeric
Hotkey, CapsLock & 7, MouseLeftUp
Hotkey, CapsLock & 8, MouseUp
Hotkey, CapsLock & 9, MouseRightUp
Hotkey, CapsLock & 4, MouseLeft
Hotkey, CapsLock & 5, MouseDown
Hotkey, CapsLock & 6, MouseRight
Hotkey, CapsLock & 1, MouseLeftDown
Hotkey, CapsLock & 2, MouseDown
Hotkey, CapsLock & 3, MouseRightDown

; Arrows
Hotkey, CapsLock & Up, MouseUp
Hotkey, CapsLock & Down, MouseDown
Hotkey, CapsLock & Left, MouseLeft
Hotkey, CapsLock & Right, MouseRight

return

Move( x, y ) {
	MouseMove, x, y, 0, R
}

MouseUp:
	Move( 0, -1 )
	return
MouseDown:
	Move( 0, 1 )
	return
MouseLeft:
	Move( -1, 0 )
	return
MouseRight:
	Move( 1, 0 )
	return
MouseLeftUp:
	Move( -1, -1 )
	return
MouseRightUp:
	Move( 1, -1 )
	return
MouseLeftDown:
	Move( -1, 1 )
	return
MouseRightDown:
	Move( 1, 1 )
	return

If Action <> 0
{
	IfNotInString, A_ThisLabel, %Action%
	{
		MouseCurrentAccelerationSpeed = 0
		MouseCurrentSpeed = %MouseSpeed%
	}
}
StringReplace, Action, A_ThisLabel, *

ButtonAccelerationStart:
If MouseAccelerationSpeed >= 1
{
	If MouseMaxSpeed > %MouseCurrentSpeed%
	{
		Temp = 0.001
		Temp *= %MouseAccelerationSpeed%
		MouseCurrentAccelerationSpeed += %Temp%
		MouseCurrentSpeed += %MouseCurrentAccelerationSpeed%
	}
}

MouseCurrentSpeedToDirection = 1

MouseCurrentSpeedToSide = 0

MouseCurrentSpeedToDirection *= %MouseCurrentSpeed%
MouseCurrentSpeedToSide *= %MouseCurrentSpeed%

Temp = 0

If Action = MouseUp
{
	MouseCurrentSpeedToDirection *= -1
	MouseMove, %MouseCurrentSpeedToSide%, %MouseCurrentSpeedToDirection%, 0, R
}
else if Action = MouseDown
{
	MouseCurrentSpeedToSide *= -1
	MouseMove, %MouseCurrentSpeedToSide%, %MouseCurrentSpeedToDirection%, 0, R
}
else if Action = MouseLeft
{
	MouseCurrentSpeedToSide *= -1
	MouseCurrentSpeedToDirection *= -1

	MouseMove, %MouseCurrentSpeedToDirection%, %MouseCurrentSpeedToSide%, 0, R
}
else if Action = MouseRight
{
	MouseMove, %MouseCurrentSpeedToDirection%, %MouseCurrentSpeedToSide%, 0, R
}
else if Action = MouseLeftUp
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp -= %MouseCurrentSpeedToSide%
	Temp *= -1
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 += %MouseCurrentSpeedToSide%
	Temp2 *= -1
	MouseMove, %Temp%, %Temp2%, 0, R
}
else if Action = MouseRightUp
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp += %MouseCurrentSpeedToSide%
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 -= %MouseCurrentSpeedToSide%
	Temp2 *= -1
	MouseMove, %Temp%, %Temp2%, 0, R
}
else if Action = MouseLeftDown
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp += %MouseCurrentSpeedToSide%
	Temp *= -1
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 -= %MouseCurrentSpeedToSide%
	MouseMove, %Temp%, %Temp2%, 0, R
}
else if Action = MouseRightDown
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp -= %MouseCurrentSpeedToSide%
	Temp2 *= -1
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 += %MouseCurrentSpeedToSide%
	MouseMove, %Temp%, %Temp2%, 0, R
}

SetTimer, ButtonAccelerationEnd, 10
return

ButtonAccelerationEnd:
GetKeyState, kstate, %Action%, P
if kstate = D
	Goto ButtonAccelerationStart

SetTimer, ButtonAccelerationEnd, off
MouseCurrentAccelerationSpeed = 0
MouseCurrentSpeed = %MouseSpeed%
Action = 0
return

; Using Keyboard Numpad as a Mouse -- by deguix
; http://www.autohotkey.com

;START OF CONFIG SECTION

#SingleInstance force
#MaxHotkeysPerInterval 500

; Using the keyboard hook to implement the Numpad hotkeys prevents
; them from interfering with the generation of ANSI characters such
; as .  This is because AutoHotkey generates such characters
; by holding down ALT and sending a series of Numpad keystrokes.
; Hook hotkeys are smart enough to ignore such keystrokes.
#UseHook

MouseSpeed = 1
MouseAccelerationSpeed = 1
MouseMaxSpeed = 5

;Mouse wheel speed is also set on Control Panel. As that
;will affect the normal mouse behavior, the real speed of
;these three below are times the normal mouse wheel speed.
MouseWheelSpeed = 1
MouseWheelAccelerationSpeed = 1
MouseWheelMaxSpeed = 5

;END OF CONFIG SECTION

;This is needed or key presses would faulty send their natural
;actions. Like NumPadDiv would send sometimes "/" to the
;screen.
#InstallKeybdHook

Temp = 0
Temp2 = 0

MouseCurrentAccelerationSpeed = 0
MouseCurrentSpeed = %MouseSpeed%

MouseWheelCurrentAccelerationSpeed = 0
MouseWheelCurrentSpeed = %MouseSpeed%

SetKeyDelay, -1
SetMouseDelay, -1

Hotkey, CapsLock & I, MouseUp
Hotkey, CapsLock & J, MouseLeft
Hotkey, CapsLock & K, MouseDown
Hotkey, CapsLock & L, MouseRight
Hotkey, CapsLock & M, MouseLeftDown
Hotkey, CapsLock & O, MouseRightUp
Hotkey, CapsLock & U, MouseLeftUp
Hotkey, CapsLock & `, , MouseDown
Hotkey, CapsLock & `. , MouseRightDown

Hotkey, CapsLock & Up, MouseUp
Hotkey, CapsLock & Down, MouseDown
Hotkey, CapsLock & Left, MouseLeft
Hotkey, CapsLock & Right, MouseRight

return

Move( x, y ) {
	MouseMove, x, y, 0, R
}

MouseUp:
	Move( 0, -1 )
	return
MouseDown:
	Move( 0, 1 )
	return
MouseLeft:
	Move( -1, 0 )
	return
MouseRight:
	Move( 1, 0 )
	return
MouseLeftUp:
	Move( -1, -1 )
	return
MouseRightUp:
	Move( 1, -1 )
	return
MouseLeftDown:
	Move( -1, 1 )
	return
MouseRightDown:
	Move( 1, 1 )
	return

If Action <> 0
{
	IfNotInString, A_ThisLabel, %Action%
	{
		MouseCurrentAccelerationSpeed = 0
		MouseCurrentSpeed = %MouseSpeed%
	}
}
StringReplace, Action, A_ThisLabel, *

ButtonAccelerationStart:
If MouseAccelerationSpeed >= 1
{
	If MouseMaxSpeed > %MouseCurrentSpeed%
	{
		Temp = 0.001
		Temp *= %MouseAccelerationSpeed%
		MouseCurrentAccelerationSpeed += %Temp%
		MouseCurrentSpeed += %MouseCurrentAccelerationSpeed%
	}
}

MouseCurrentSpeedToDirection = 1

MouseCurrentSpeedToSide = 0

MouseCurrentSpeedToDirection *= %MouseCurrentSpeed%
MouseCurrentSpeedToSide *= %MouseCurrentSpeed%

Temp = 0

If Action = MouseUp
{
	MouseCurrentSpeedToDirection *= -1
	MouseMove, %MouseCurrentSpeedToSide%, %MouseCurrentSpeedToDirection%, 0, R
}
else if Action = MouseDown
{
	MouseCurrentSpeedToSide *= -1
	MouseMove, %MouseCurrentSpeedToSide%, %MouseCurrentSpeedToDirection%, 0, R
}
else if Action = MouseLeft
{
	MouseCurrentSpeedToSide *= -1
	MouseCurrentSpeedToDirection *= -1

	MouseMove, %MouseCurrentSpeedToDirection%, %MouseCurrentSpeedToSide%, 0, R
}
else if Action = MouseRight
{
	MouseMove, %MouseCurrentSpeedToDirection%, %MouseCurrentSpeedToSide%, 0, R
}
else if Action = MouseLeftUp
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp -= %MouseCurrentSpeedToSide%
	Temp *= -1
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 += %MouseCurrentSpeedToSide%
	Temp2 *= -1
	MouseMove, %Temp%, %Temp2%, 0, R
}
else if Action = MouseRightUp
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp += %MouseCurrentSpeedToSide%
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 -= %MouseCurrentSpeedToSide%
	Temp2 *= -1
	MouseMove, %Temp%, %Temp2%, 0, R
}
else if Action = MouseLeftDown
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp += %MouseCurrentSpeedToSide%
	Temp *= -1
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 -= %MouseCurrentSpeedToSide%
	MouseMove, %Temp%, %Temp2%, 0, R
}
else if Action = MouseRightDown
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp -= %MouseCurrentSpeedToSide%
	Temp2 *= -1
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 += %MouseCurrentSpeedToSide%
	MouseMove, %Temp%, %Temp2%, 0, R
}

SetTimer, ButtonAccelerationEnd, 10
return

ButtonAccelerationEnd:
GetKeyState, kstate, %Action%, P
if kstate = D
	Goto ButtonAccelerationStart

SetTimer, ButtonAccelerationEnd, off
MouseCurrentAccelerationSpeed = 0
MouseCurrentSpeed = %MouseSpeed%
Action = 0
return


Foobar2000 plugin: map <esc> to <RemoveToolTip>

Foobar2000:
    global Foobar2000_name := "Foobar2000"
    global Foobar2000_class := "{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}"
    global Foobar2000_exe := "Foobar2000.exe"
    global Foobar2000_list_classnn := "{4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1"

    ;vim.comment("<Foobar2000_NormalMode>", "进入normal模式")
    ;vim.comment("<Foobar2000_InsertMode>", "进入insert模式")
    vim.comment("<Foobar2000_Search>", "打开搜索窗口")
    vim.comment("<Foobar2000_Tree>", "定位到目录窗口")
    vim.comment("<Foobar2000_List>", "定位到播放列表")
    vim.comment("<Foobar2000_ToggleShowInfo>", "显示/隐藏 按键提示")

    /*
    ; insert模式
    vim.mode("insert", Foobar2000_name)
    vim.map("<esc>", "<Foobar2000_NormalMode>", Foobar2000_name)
    */

    ; normal模式
    vim.SetWin(Foobar2000_name, Foobar2000_class, Foobar2000_exe)
    vim.mode("normal", Foobar2000_name)

    ;vim.map("i", "<Foobar2000_InsertMode>", Foobar2000_name)
    vim.map("<esc>", "<RemoveToolTip>", Foobar2000_name)

    vim.map("0", "<0>", Foobar2000_name)
    vim.map("1", "<1>", Foobar2000_name)
    vim.map("2", "<2>", Foobar2000_name)
    vim.map("3", "<3>", Foobar2000_name)
    vim.map("4", "<4>", Foobar2000_name)
    vim.map("5", "<5>", Foobar2000_name)
    vim.map("6", "<6>", Foobar2000_name)
    vim.map("7", "<7>", Foobar2000_name)
    vim.map("8", "<8>", Foobar2000_name)
    vim.map("9", "<9>", Foobar2000_name)

    vim.map("j", "<down>", Foobar2000_name)
    vim.map("k", "<up>", Foobar2000_name)
    vim.map("l", "<enter>", Foobar2000_name)
    vim.map("gg", "<home>", Foobar2000_name)
    vim.map("G", "<end>", Foobar2000_name)
    vim.map("<c-f>", "<pgdn>", Foobar2000_name)
    vim.map("<c-b>", "<pgup>", Foobar2000_name)
    vim.map("/", "<Foobar2000_Search>", Foobar2000_name)
    vim.map("t", "<Foobar2000_Tree>", Foobar2000_name)
    vim.map("m", "<Foobar2000_List>", Foobar2000_name)
    vim.map("n", "<Media_Next>", Foobar2000_name)
    vim.map("p", "<Media_Prev>", Foobar2000_name)
    vim.map("s", "<Media_Stop>", Foobar2000_name)

    vim.map("N", "<NextTab>", Foobar2000_name)
    vim.map("P", "<PrevTab>", Foobar2000_name)

    vim.map("``", "<Foobar2000_ToggleShowInfo>", Foobar2000_name)

    vim.BeforeActionDo("ForceNormalMode_Foobar2000", Foobar2000_name)
return

ForceNormalMode_Foobar2000()
{
    ControlGetFocus, ctrl, AHK_CLASS %Foobar2000_name%
    ; msgbox, ctrl
    if RegExMatch(ctrl, "Edit2")
        return true
    return false
}

/*
<Foobar2000_NormalMode>:
    DisplayMode(Foobar2000_name, "normal")

    vim.mode("normal", Foobar2000_name)
return

<Foobar2000_InsertMode>:
    DisplayMode(Foobar2000_name, "insert")

    vim.mode("insert", Foobar2000_name)
return
*/

<Foobar2000_Search>:
    send ^f
return

<Foobar2000_Tree>:
    ControlFocus, SysTreeView321
return

<Foobar2000_List>:
    ControlFocus, %Foobar2000_list_classnn%
return

<Foobar2000_ToggleShowInfo>:
    vim.GetWin(Foobar2000_name).SetInfo(!vim.GetWin(Foobar2000_name).info)
return

Foobar2000:
    global Foobar2000_name := "Foobar2000"
    global Foobar2000_class := "{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}"
    global Foobar2000_exe := "Foobar2000.exe"
    global Foobar2000_list_classnn := "{4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1"

    ;vim.comment("<Foobar2000_NormalMode>", "进入normal模式")
    ;vim.comment("<Foobar2000_InsertMode>", "进入insert模式")
    vim.comment("<Foobar2000_Search>", "打开搜索窗口")
    vim.comment("<Foobar2000_Tree>", "定位到目录窗口")
    vim.comment("<Foobar2000_List>", "定位到播放列表")
    vim.comment("<Foobar2000_ToggleShowInfo>", "显示/隐藏 按键提示")

    /*
    ; insert模式
    vim.mode("insert", Foobar2000_name)
    vim.map("<esc>", "<Foobar2000_NormalMode>", Foobar2000_name)
    */

    ; normal模式
    vim.SetWin(Foobar2000_name, Foobar2000_class, Foobar2000_exe)
    vim.mode("normal", Foobar2000_name)

    ;vim.map("i", "<Foobar2000_InsertMode>", Foobar2000_name)

    vim.map("0", "<0>", Foobar2000_name)
    vim.map("1", "<1>", Foobar2000_name)
    vim.map("2", "<2>", Foobar2000_name)
    vim.map("3", "<3>", Foobar2000_name)
    vim.map("4", "<4>", Foobar2000_name)
    vim.map("5", "<5>", Foobar2000_name)
    vim.map("6", "<6>", Foobar2000_name)
    vim.map("7", "<7>", Foobar2000_name)
    vim.map("8", "<8>", Foobar2000_name)
    vim.map("9", "<9>", Foobar2000_name)

    vim.map("j", "<down>", Foobar2000_name)
    vim.map("k", "<up>", Foobar2000_name)
    vim.map("l", "<enter>", Foobar2000_name)
    vim.map("gg", "<home>", Foobar2000_name)
    vim.map("G", "<end>", Foobar2000_name)
    vim.map("<c-f>", "<pgdn>", Foobar2000_name)
    vim.map("<c-b>", "<pgup>", Foobar2000_name)
    vim.map("/", "<Foobar2000_Search>", Foobar2000_name)
    vim.map("t", "<Foobar2000_Tree>", Foobar2000_name)
    vim.map("m", "<Foobar2000_List>", Foobar2000_name)
    vim.map("n", "<Media_Next>", Foobar2000_name)
    vim.map("p", "<Media_Prev>", Foobar2000_name)
    vim.map("s", "<Media_Stop>", Foobar2000_name)

    vim.map("N", "<NextTab>", Foobar2000_name)
    vim.map("P", "<PrevTab>", Foobar2000_name)

    vim.map("``", "<Foobar2000_ToggleShowInfo>", Foobar2000_name)

    vim.BeforeActionDo("ForceNormalMode_Foobar2000", Foobar2000_name)
return

ForceNormalMode_Foobar2000()
{
    ControlGetFocus, ctrl, AHK_CLASS %Foobar2000_name%
    ; msgbox, ctrl
    if RegExMatch(ctrl, "Edit2")
        return true
    return false
}

/*
<Foobar2000_NormalMode>:
    DisplayMode(Foobar2000_name, "normal")

    vim.mode("normal", Foobar2000_name)
return

<Foobar2000_InsertMode>:
    DisplayMode(Foobar2000_name, "insert")

    vim.mode("insert", Foobar2000_name)
return
*/

<Foobar2000_Search>:
    send ^f
return

<Foobar2000_Tree>:
    ControlFocus, SysTreeView321
return

<Foobar2000_List>:
    ControlFocus, %Foobar2000_list_classnn%
return

<Foobar2000_ToggleShowInfo>:
    vim.GetWin(Foobar2000_name).SetInfo(!vim.GetWin(Foobar2000_name).info)
return


Update WIP.ahk

Update WIP.ahk

;In the Header we define declares which need to be added to the Header of the script (or to the .def files if they exist)
Header =
(
Declare Sub stringToFile(ByVal strToWrite As String, ByVal sFilePath As String)
Declare Function BaseA_to_Base10(ByVal BaseA As Integer, ByVal Value As String, ByVal signedByte As Logical) As SmallInt 'as long
Declare Sub splitStringToArray(ByVal someString As String, ByVal delimitLength As Integer, strArr() as string)
)

;In the footer we define the inner workings of the functions/subroutines declared in header
Footer =
(
'~~~~~~~~~~~~~~~~~~~~~~~~~~ GENERATED BY EMB INCLUDEFILE ~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub stringToFile(ByVal strToWrite As String, ByVal sFilePath As String)
	Dim strArr() As String

	'get array of character pairs		'splitStringToArray sub-routine ported to MapBasic
	Call splitStringToArray(strToWrite, 3, strArr)

	'Write binary file
	Dim i As Integer, filePart As SmallInt, nFileNum As Integer

	If Not FileExists(sFilePath) then
		Open File sFilePath for Output as #1
		Close File #1
	End If

	' Open the file in binary mode.  Locks are optional
	Open File sFilePath For Binary Access Read Write As #1
	   ' Put the data in the file
	   For i = 1 To UBound(strArr)
		   'Write information as integers (THIS IS A MUST!)
		   filePart = BaseA_to_Base10(64, strArr(i), 1)

		   ' No byte position is specified so writing begins at byte 1
		   Put #1, , filePart
	   Next
	Close File #1
End Sub

Function BaseA_to_Base10(ByVal BaseA As Integer, ByVal Value As String, ByVal signedByte As Logical) As SmallInt
	Dim char As String, i, e, sum As Integer
	Define Base64 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"

	'Find BaseA's character range
	Dim sBaseACharRange As String
	sBaseACharRange = Left$(Base64, BaseA)

	For i = Len(Value) To 1 Step -1
		char = Mid$(Value, i, 1)
		If BaseA > 64 Then
			'Base 256
			e = Asc(char)
		Else
			'Base 0 --> 64
			e = InStr(1, sBaseACharRange, char) - 1

			'Error -999999 <-- Character is not not found in Base definition
			If e = -1 Then
				  BaseA_to_Base10 = -999999
				  Exit Function
			  End If
		End If

		'Calculate sum. This will be eventually returned
		sum = sum + e * BaseA ^ (Len(Value) - i)
	Next

	'Negatives for signed bytes
	If signedByte And sum > BaseA ^ Len(Value) / 2 Then
		sum = sum - BaseA ^ Len(Value)
	End If

	'Return sum
	BaseA_to_Base10 = sum
End Function

Sub splitStringToArray(ByVal someString As String, ByVal delimitLength As Integer, strArr() as string)
	Dim i As Integer, j As Integer
	j = 1

	ReDim strArr(Int(Len(someString) / delimitLength))

	For i = 1 To Len(someString) Step delimitLength
		strArr(j) = Mid$(someString, i, delimitLength)
		j = j + 1
	Next
End Sub
)

;~~~~~~~~~~~~~~~~~~~~~~~~~~ EMB INCLUDEFILE ~~~~~~~~~~~~~~~~~~~~~~~~~~
;Developers: Sancarn
;Contributors:
;GUID: {}

;TODO:
  ; filepath variable declarations
  ; filedata variable declarations
  ; getFileData
  ; concatenate with MB

;String to do actions on is MBSource
MB := MBSource
sFilePaths := []
sFileVars := []

;Main Regex: Include\s+"(.*)"\s*,\s*(\w+)\s+as\s+string
pattern := "iO)" . "Include\s+"((?!.*Include).*?)"\s*,\s*((?!as\b)\w+)\s+as\s+string"

;What does the regex mean?
;~~~~~~~~~~~~~~~~~~~~~~~~~
;The desired match should consist of 'Include "<some characters>" , <some variable name> as string'
;The following is an illegal match 'Include "<some characters> Include" , <some variable name> as string'
;The following is an illegal match 'Include "<some characters>" as as string'
;But this is a legal match 	   'Include "<some characters>" asd as string'
;As well as			   'Include "<some characters>" bas as string'
;Prefix Option "i" makes the regex case insensitive.
;Prefix Option "O" makes the regex return an object.
;The following match is legal: 'Include "someImage.png", someImage as string' in 'Include "someScript.mb"Include "someImage.png", someImage as string'

;Test this regex
;~~~~~~~~~~~~~~~~~~~~~~~~~
;https://regex101.com/r/zA3tP7/1

match = RegExMatch(MB, pattern, mObj, 1)

If match <> "" {
   while match <> ""
   {
      ;Get captured strings
      sFilePaths.push(match1)
      sFileVars.push(match2)

      ;Remove the match from MB
      MB := ImportFiles_MidInvert(MB,match, mObj.Len())

      ;Find the next match
      match = RegExMatch(MB, pattern, mObj, match)
   }  ;All 'Include "someFile", asdf as string' have been removed from MB. MB therefore contains the 'most complete' script so far

  ; filepath variable declarations
  sJoin := ImportFiles_StrJoin(sFileVars,",")
  header = %header%`r`nDim %sJoin% as string

  ;Next steps, generate
  ; filedata variable declarations
  ; getFileData
  ; concatenate with MB
}

ImportFiles_MidInvert(sSrc, iStart, iLen){
  ;This function does the oppisite of mid. Instead of extracting a part of a string and returning the extracted part, in this case we are returning the part after extraction. You can imagine this as if we were replacing the string returned from mid() with null.
  ;Examples
  ;~~~~~~~~~~~~~~~~
  ;MidInvert("https://regex101.com/r/zA3tP7/1",6,11)  returns "https.com/r/zA3tP7/1"
  ;MidInvert("https://regex101.com/r/zA3tP7/1",1,8)   returns "regex101.com/r/zA3tP7/1"
  ;MidInvert("https://regex101.com/r/zA3tP7/1",30,8)  returns "1"

  ;If iStart is less than 1 then there is no leftPart
  if (iStart > 1){
    leftPart := subStr(sSrc,1,iStart-1)
  }

  ;If iStart+iLen is greater than the length of the string, there can't be a right part
  if iStart+iLen >= strlen(sSrc){
    rightPart := subStr(sSrc,iStart + iLen)
  }

  ;Return concatenation of the left and right parts.
  return leftPart . rightPart
}

;Code by Pulover - https://github.com/Pulover/Eval/blob/master/Eval.ahk
ImportFiles_StrJoin(InputArray, JChr := "", Quote := false, Init := true)
{
	For i, v in InputArray
	{
		If (IsObject(v))
			return v
		If v is not Number
		{
			If (!Init)
				v := RegExReplace(v, """{1,2}", """""")
			If (Quote)
				v := """" v """"
		}
		JoinedStr .= v . JChr
	}
	If (JChr != "")
		JoinedStr := SubStr(JoinedStr, 1, -(StrLen(JChr)))
	return JoinedStr
}

;In the Header we define declares which need to be added to the Header of the script (or to the .def files if they exist)
Header =
(
Declare Sub stringToFile(ByVal strToWrite As String, ByVal sFilePath As String)
Declare Function BaseA_to_Base10(ByVal BaseA As Integer, ByVal Value As String, ByVal signedByte As Logical) As SmallInt 'as long
Declare Sub splitStringToArray(ByVal someString As String, ByVal delimitLength As Integer, strArr() as string)
)

;In the footer we define the inner workings of the functions/subroutines declared in header
Footer =
(
'~~~~~~~~~~~~~~~~~~~~~~~~~~ GENERATED BY EMB INCLUDEFILE ~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub stringToFile(ByVal strToWrite As String, ByVal sFilePath As String)
	Dim strArr() As String

	'get array of character pairs		'splitStringToArray sub-routine ported to MapBasic
	Call splitStringToArray(strToWrite, 3, strArr)

	'Write binary file
	Dim i As Integer, filePart As SmallInt, nFileNum As Integer

	If Not FileExists(sFilePath) then
		Open File sFilePath for Output as #1
		Close File #1
	End If

	' Open the file in binary mode.  Locks are optional
	Open File sFilePath For Binary Access Read Write As #1
	   ' Put the data in the file
	   For i = 1 To UBound(strArr)
		   'Write information as integers (THIS IS A MUST!)
		   filePart = BaseA_to_Base10(64, strArr(i), 1)

		   ' No byte position is specified so writing begins at byte 1
		   Put #1, , filePart
	   Next
	Close File #1
End Sub

Function BaseA_to_Base10(ByVal BaseA As Integer, ByVal Value As String, ByVal signedByte As Logical) As SmallInt
	Dim char As String, i, e, sum As Integer
	Define Base64 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"

	'Find BaseA's character range
	Dim sBaseACharRange As String
	sBaseACharRange = Left$(Base64, BaseA)

	For i = Len(Value) To 1 Step -1
		char = Mid$(Value, i, 1)
		If BaseA > 64 Then
			'Base 256
			e = Asc(char)
		Else
			'Base 0 --> 64
			e = InStr(1, sBaseACharRange, char) - 1

			'Error -999999 <-- Character is not not found in Base definition
			If e = -1 Then
				  BaseA_to_Base10 = -999999
				  Exit Function
			  End If
		End If

		'Calculate sum. This will be eventually returned
		sum = sum + e * BaseA ^ (Len(Value) - i)
	Next

	'Negatives for signed bytes
	If signedByte And sum > BaseA ^ Len(Value) / 2 Then
		sum = sum - BaseA ^ Len(Value)
	End If

	'Return sum
	BaseA_to_Base10 = sum
End Function

Sub splitStringToArray(ByVal someString As String, ByVal delimitLength As Integer, strArr() as string)
	Dim i As Integer, j As Integer
	j = 1

	ReDim strArr(Int(Len(someString) / delimitLength))

	For i = 1 To Len(someString) Step delimitLength
		strArr(j) = Mid$(someString, i, delimitLength)
		j = j + 1
	Next
End Sub
)

;~~~~~~~~~~~~~~~~~~~~~~~~~~ EMB INCLUDEFILE ~~~~~~~~~~~~~~~~~~~~~~~~~~
;Developers: Sancarn
;Contributors:
;GUID: {}

;TODO:
  ; filepath variable declarations
  ; filedata variable declarations
  ; getFileData
  ; concatenate with MB

;String to do actions on is MBSource
MB := MBSource
sFilePaths := []
sFileVars := []

;Main Regex: Include\s+"(.*)"\s*,\s*(\w+)\s+as\s+string
pattern := "iO)" . "Include\s+"((?!.*Include).*?)"\s*,\s*(\w+)\s+as\s+string"

;What does the regex mean?
;~~~~~~~~~~~~~~~~~~~~~~~~~
;The desired match should consist of 'Include "<some characters>" , <some variable name> as string'
;The following is an illegal match 'Include "<some characters> Include" , <some variable name> as string'
;Prefix Option "i" makes the regex case insensitive.
;Prefix Option "O" makes the regex return an object.
;The following match is legal: 'Include "someImage.png", someImage as string' in 'Include "someScript.mb"Include "someImage.png", someImage as string'

;Test this regex
;~~~~~~~~~~~~~~~~~~~~~~~~~
;https://regex101.com/r/zA3tP7/1

match = RegExMatch(MB, pattern, mObj, 1)

If match <> "" {
   while match <> ""
   {
      ;Get captured strings
      sFilePaths.push(match1)
      sFileVars.push(match2)

      ;Remove the match from MB
      MB := ImportFiles_MidInvert(MB,match, mObj.Len())

      ;Find the next match
      match = RegExMatch(MB, pattern, mObj, match)
   }

  ;All 'Include "someFile", asdf as string' have been removed from MB. MB therefore contains the 'most complete' script so far
  ;Next steps, generate
  ; filepath variable declarations
  ; filedata variable declarations
  ; getFileData
  ; concatenate with MB
}

ImportFiles_MidInvert(sSrc, iStart, iLen){
  ;This function does the oppisite of mid. Instead of extracting a part of a string and returning the extracted part, in this case we are returning the part after extraction. You can imagine this as if we were replacing the string returned from mid() with null.
  ;Examples
  ;~~~~~~~~~~~~~~~~
  ;MidInvert("https://regex101.com/r/zA3tP7/1",6,11)  returns "https.com/r/zA3tP7/1"
  ;MidInvert("https://regex101.com/r/zA3tP7/1",1,8)   returns "regex101.com/r/zA3tP7/1"
  ;MidInvert("https://regex101.com/r/zA3tP7/1",30,8)  returns "1"

  ;If iStart is less than 1 then there is no leftPart
  if (iStart > 1){
    leftPart := subStr(sSrc,1,iStart-1)
  }

  ;If iStart+iLen is greater than the length of the string, there can't be a right part
  if iStart+iLen >= strlen(sSrc){
    rightPart := subStr(sSrc,iStart + iLen)
  }

  ;Return concatenation of the left and right parts.
  return leftPart . rightPart
}