Skip to content

Instantly share code, notes, and snippets.

View tablacus's full-sized avatar

Gaku tablacus

View GitHub Profile
@tablacus
tablacus / copyfilename.js
Last active October 8, 2021 13:21
Copy file name to clipboard - Tablacus Explorer
clipboardData.setData("text", (FV.FocusedItem || FV.FolderItem).Name);
@tablacus
tablacus / widerightclick.js
Created September 16, 2021 10:59
Wide right click - Tablacus Explorer
const iItem = FV.HitTest(pt, LVHT_ONITEM);
if (iItem >= 0) {
FV.SelectItem(iItem, SVSI_SELECT | SVSI_FOCUSED | SVSI_DESELECTOTHERS);
}
return S_FALSE;
@tablacus
tablacus / savelayoutow.js
Created July 19, 2021 11:09
Save layout overwrite
if (te.Data.LayoutPath) {
SaveXml(te.Data.LayoutPath);
} else {
SaveLayout();
}
return S_OK;
@tablacus
tablacus / loadlayoutow.js
Created July 19, 2021 11:07
Load layout overwrite
const commdlg = api.CreateObject("CommonDialog");
commdlg.InitDir = BuildPath(te.Data.DataFolder, "layout");
commdlg.Filter = MakeCommDlgFilter("*.xml");
commdlg.Flags = OFN_FILEMUSTEXIST;
if (commdlg.ShowOpen()) {
te.Data.LayoutPath = commdlg.FileName;
LoadXml(commdlg.FileName);
}
return S_OK;
@tablacus
tablacus / focustreeviewfrominneraddressbar.js
Last active June 20, 2021 01:08
Focus Tree view from Inner Address bar - Tablacus Explorer
window.addEventListener("keydown", function (ev) {
if (ev.keyCode == VK_TAB) {
const res = /inneraddressbar_(\d+)/i.exec((ev.target || ev.srcElement).id);
if (res) {
setTimeout(async function () {
const FV = te.Ctrl(CTRL_TC, res[1]).Selected;
FV.Focus();
FV.TreeView.Focus();
}, 99);
if (ev.preventDefault) {
@tablacus
tablacus / selecttotop.js
Last active March 21, 2021 13:27
All selected items on top of the list - Tablacus Explorer
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 / openInOtherPane.js
Created February 23, 2021 12:19
The same folder to open in the other pane. (* Add-on "Switch to next pane" is required.)
const FV = GetFolderView(Ctrl, pt);
NavigateFV(Sync.SwitchPane.NextFV(FV), FV, SBSP_SAMEBROWSER);
@tablacus
tablacus / activatecolor.js
Created August 20, 2020 15:55
Change toolbar background color on activation/deactivation - Tablacus Explorer
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 August 17, 2020 15:11
Auto arrange on rename - Tablacus Explorer
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
Last active June 5, 2021 12:18
Decrement badges - Tablacus Explorer
const Selected = GetSelectedArray(Ctrl, pt, true).shift();
if (Selected && Selected.Count) {
for (let i = Selected.Count; i-- > 0;) {
const path = Selected.Item(i).Path;
const s = GetNum(Sync.Badge.DB.Get(path)) - 1;
if (s >= 0) {
Sync.Badge.Set(path, s);
}
}
}