Last active
June 1, 2022 01:45
-
-
Save chenyue404/a450719f3a57ce76485cec30a7728648 to your computer and use it in GitHub Desktop.
qttabbar脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 打开选中文件夹或者当前文件夹的,最后一个不是单文件夹的路径。 | |
var qs = new ActiveXObject("QTTabBarLib.Scripting"); | |
var fso = new ActiveXObject("Scripting.FileSystemObject"); | |
var wnd = qs.activewindow; | |
if (wnd) { | |
var activeTab = wnd.ActiveTab; | |
var selectedItems = wnd.SelectedItems | |
var currentPath = activeTab.Path; | |
var selectedFolderPath = "" | |
if (selectedItems.Count == 1) { | |
var curPath = selectedItems.Item(0); | |
if (fso.FolderExists(curPath)) { | |
currentPath = curPath; | |
selectedFolderPath = curPath; | |
} | |
} | |
while (onlyOneFolder(currentPath)) { | |
var currentFolderObject = fso.GetFolder(currentPath); | |
var enumerator = new Enumerator(currentFolderObject.SubFolders); | |
for (; !enumerator.atEnd(); enumerator.moveNext()) { | |
currentPath = enumerator.item().Path; | |
} | |
} | |
if (currentPath != activeTab.Path && currentPath != selectedFolderPath) { | |
qs.InvokeCommand("OpenInPlace", currentPath); | |
} else if (selectedFolderPath != "") { | |
qs.InvokeCommand("OpenInPlace", selectedFolderPath); | |
} else { | |
qs.alert("当前目录并非只有一个文件夹"); | |
} | |
} | |
function onlyOneFolder(currentPath) { | |
var currentFolderObject = fso.GetFolder(currentPath); | |
var folderCount = currentFolderObject.SubFolders.Count; | |
var fileCount = currentFolderObject.Files.Count; | |
var result = fileCount == 0 && folderCount == 1 | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 在新tab打开我的电脑 | |
var qs = new ActiveXObject("QTTabBarLib.Scripting"); | |
var fso = new ActiveXObject("Scripting.FileSystemObject"); | |
var wnd = qs.activewindow; | |
if (wnd) { | |
var activeTab = wnd.ActiveTab; | |
var currentPath = activeTab.Path; | |
var myComputer = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"; | |
if (currentPath == myComputer) { | |
wnd.InvokeCommand("CloneTab"); | |
} else { | |
wnd.InvokeCommand("NewTab", myComputer); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment