在VSCode 当中打开一个文件夹,同时打开一个文件 + AutoHotkey 用 VSCo打开选中的文件

Opening a Folder and File in Vscode from Terminal | JagaScript

code path_to_foder --goto path_to_file

AHK

注意把VSCode的根目录添加到环境变量(并且用code.exe 调用),否则可能无法Run


CapsLock & s:: ; sublime
folder := GetActiveExplorerPath()
file := GetSelectedFilePath()
if(folder != "")
{
  Run, % "subl """ . file . """ -a """ . folder . """ ", , Hide, ; add folder
}
else if(file != "")
{
  Run, % "subl """ . file . """" , Hide, ; without folder
}
Return 

CapsLock & v::
folder := GetActiveExplorerPath()
file := GetSelectedFilePath()
cmd := "code -n """ . file . """ -a """ . folder . """"
if(folder != "")
{
  ; Run, % "code"
  Run, % "code """ . folder . """ --goto """ . file . """", , Hide, ; add folder
}
else if(file != "")
{
  Run, % "code -n """ . file . """" , Hide, ; without folder
}
; code -n "D:\Data\Programs\UserData\Caesium\1.jpg" -a "D:\Data\Programs\UserData\Caesium"
Return 

GetActiveExplorerPath()
{
	explorerHwnd := WinActive("A")
  if (explorerHwnd)
	{
		for window in ComObjCreate("Shell.Application").Windows
		{
			if (window.hwnd==explorerHwnd)
			{
        folder := window.Document.Folder.Self.Path
				return folder
			}
		}
	}
}

GetSelectedFilePath()
{
  hwnd := WinExist("A")
  for Window in ComObjCreate("Shell.Application").Windows  
      if (window.hwnd==hwnd) {
          Selection := Window.Document.SelectedItems
          for Items in Selection
              Path_to_Selection := Items.path
  }
  Return Path_to_Selection
}
上一篇:Linux Shell 分别解压目录下所有zip文件到以其文件名命名的单独文件夹


下一篇:java基础