Skip to content

Instantly share code, notes, and snippets.

Avatar

Gaku tablacus

View GitHub Profile
@tablacus
tablacus / BetweenFilesAndFolders.js
Last active Apr 27, 2021
Jump to the boundary between files and folders
View BetweenFilesAndFolders.js
var FV = GetFolderView(Ctrl,pt);
var Items = FV.Items();
var bFolder = !IsFolderEx(Items.Item(0));
var nCount = Items.Count;
var nIndex = Math.floor((nCount - 1) / 2);
var nDiff = nIndex;
while (nDiff) {
if (bFolder ^ IsFolderEx(Items.Item(nIndex))) {
nIndex += nDiff;
} else {
@tablacus
tablacus / selecttotop.js
Last active Mar 21, 2021
All selected items on top of the list - Tablacus Explorer
View selecttotop.js
const FV = GetFolderView(Ctrl, pt);
const Selected = FV.Items(SVGIO_SELECTION | SVGIO_FLAG_VIEWORDER);
const Progress = api.CreateObject("ProgressDialog");
Progress.StartProgressDialog(te.hwnd, null, 2);
const Name = GetText("Selected items");
try {
FV.SelectItem(null, SVSI_DESELECTOTHERS);
const IconSize = FV.IconSize;
const ViewMode = api.SendMessage(FV.hwndList, LVM_GETVIEW, 0, 0);
if (ViewMode == 1 || ViewMode == 3) {
@tablacus
tablacus / openselectednextpane.js
Last active Feb 23, 2021
Open selected items in next pane. (Require an add-on "Switch to next pane") - Tablacus Explorer
View openselectednextpane.js
let FV = GetFolderView(Ctrl, pt);
const Selected = FV.SelectedItems();
if (Selected.Count) {
FV = Sync.SwitchPane.NextFV(FV);
for (let i = 0; i < Selected.Count; i++) {
NavigateFV(FV, Selected.Item(i), SBSP_NEWBROWSER);
}
}
@tablacus
tablacus / movetonextpane.js
Last active Feb 23, 2021
Move current tab to next pane * require "Switch to next pane" - Tablacus Explorer
View movetonextpane.js
var FV = GetFolderView(Ctrl, pt);
var FV2 = Sync.SwitchPane.NextFV(Ctrl);
FV.Parent.Move(FV.Parent.SelectedIndex, FV2.Parent.Count, FV2.Parent);
@tablacus
tablacus / openInOtherPane.js
Created Feb 23, 2021
The same folder to open in the other pane. (* Add-on "Switch to next pane" is required.)
View openInOtherPane.js
const FV = GetFolderView(Ctrl, pt);
NavigateFV(Sync.SwitchPane.NextFV(FV), FV, SBSP_SAMEBROWSER);
@tablacus
tablacus / ResetTreeView.js
Last active Sep 23, 2020
Reset tree view
View ResetTreeView.js
var FV = GetFolderView(Ctrl, pt);
if (FV) {
var TV = FV.TreeView;
if (TV) {
var hwnd = TV.hwndTree;
for (var hItem = api.SendMessage(hwnd, TVM_GETNEXTITEM, 0, null); hItem; hItem = api.SendMessage(hwnd, TVM_GETNEXTITEM, 1, hItem)) {
api.SendMessage(hwnd, TVM_EXPAND, 0x8001, hItem);
}
TV.Expand(FV.FolderItem, 0);
}
@tablacus
tablacus / ResetSideTreeView.js
Last active Sep 23, 2020
Reset side tree view
View ResetSideTreeView.js
var TV = Addons.SideTreeView.TV;
if (TV) {
var hwnd = TV.hwndTree;
for (var hItem = api.SendMessage(hwnd, TVM_GETNEXTITEM, 0, null); hItem; hItem = api.SendMessage(hwnd, TVM_GETNEXTITEM, 1, hItem)) {
api.SendMessage(hwnd, TVM_EXPAND, 0x8001, hItem);
}
var FV = GetFolderView(Ctrl, pt);
if (FV) {
TV.Expand(FV.FolderItem, 0);
}
@tablacus
tablacus / activatecolor.js
Created Aug 20, 2020
Change toolbar background color on activation/deactivation - Tablacus Explorer
View activatecolor.js
AddEvent("SystemMessage", function (Ctrl, hwnd, msg, wParam, lParam) {
if (msg == WM_ACTIVATE) {
document.body.style.backgroundColor = wParam ? "#F0F0F0" : "#757575";
}
});
@tablacus
tablacus / autoarrangeonrename.js
Last active Aug 17, 2020
Auto arrange on rename - Tablacus Explorer
View autoarrangeonrename.js
AddEvent("ChangeNotify", function (Ctrl, pidls, wParam, lParam) {
if (pidls.lEvent & (SHCNE_RENAMEITEM | SHCNE_RENAMEFOLDER)) {
var pid = api.ILGetParent(pidls[1]);
api.SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_IDLIST, pid, null);
var FV = GetFolderView();
if (FV && api.ILIsEqual(FV, pid)) {
if (FV.ItemCount(SVGIO_SELECTION) == 1) {
setTimeout(function() {
var Selected = FV.SelectedItems();
if (api.ILIsEqual(Selected.Item(0), pidls[1])) {
@tablacus
tablacus / decBadges.js
Created Aug 15, 2020
Decrement badges - Tablacus Explorer
View decBadges.js
var Selected = GetSelectedArray(Ctrl, pt, true).shift();
if (Selected && Selected.Count) {
for (var i = Selected.Count; i-- > 0;) {
var path = api.GetDisplayNameOf(Selected.Item(i), SHGDN_FORADDRESSBAR | SHGDN_FORPARSING | SHGDN_ORIGINAL);
var s = api.LowPart(Addons.Badge.DB.Get(path)) - 1;
if (s >= 0) {
Addons.Badge.Set(path, s);
}
}
}