te Reference (te.xxxxx)

Reference for te, the global object available to Tablacus Explorer scripts.

Table of Contents

  1. Getting Controls
  2. Creating Objects
  3. Script-Wide Data
  4. Window and Drawing Control
  5. Numeric Setting Properties
  6. String Setting Properties
  7. Events (te.OnXxx)
  8. Constants
  9. Members of the Objects Returned by te.Ctrl
  10. Deprecated / Internal

1. Getting Controls

te.Ctrl(type [, id])

Gets a single control.

type Return value Meaning of id
CTRL_FV / CTRL_SB / CTRL_EB ShellBrowser (file view) A 1-based serial number. If omitted, the view of the current tab (created if there is none)
CTRL_TV The tree (TreeView) of that ShellBrowser Same as above
CTRL_TC Tab control (TabCtrl) A 1-based number. 0 or omitted is the current tab control
CTRL_WB WebBrowser (of the calling window; for a sub-window, that window's WebBrowser) Not used
CTRL_FI The FolderItems being enumerated whose session ID matches Session ID

If there is no match, empty (undefined) is returned.

const FV = te.Ctrl(CTRL_FV);   // the current view
const TC = te.Ctrl(CTRL_TC);   // the current tab control

te.Ctrls(type [, bVisibleOnly [, bSafeArray]])

Returns all controls of the specified kind as an array.

Argument Description
type CTRL_FV/CTRL_SB/CTRL_EB/CTRL_TV/CTRL_TC/CTRL_WB
bVisibleOnly true returns only the visible ones (for CTRL_TV, only the trees that are shown). Omitted/false returns all
bSafeArray true returns a SafeArray. Omitted/false returns an array object (with legacy-compatible methods)
const arFV = te.Ctrls(CTRL_FV, true);      // the visible views
for (let i = 0; i < arFV.length; i++) { /* arFV[i] */ }

te.CtrlFromPoint(pt)

Returns the control under the screen coordinates pt (a POINT or similar).

te.CtrlFromWindow(hwnd)

Returns the control that corresponds to a window handle.

te.CreateCtrl(type, ...)

Creates a new control. The arguments differ depending on type.

type Call Description
CTRL_TC te.CreateCtrl(CTRL_TC, p1, p2, p3, p4, p5) 5 or more arguments are required. Each argument is set as a setting of the tab control (in the order equivalent to Left, Top, Width, Height, Style), and it is shown after creation
CTRL_SW te.CreateCtrl(CTRL_SW, url, arguments, parent, width, height [, x, y]) Creates an independent sub-window (WebBrowser). parent is an hwnd or a control. If x and y are omitted, it is centered on the parent. It is adjusted so that it does not extend off the screen
CTRL_TV te.CreateCtrl(CTRL_TV) Creates a new tree view

arguments can be obtained once, as te.Arguments, on the side of the window that was created.

te.ArrangeCB(TC, rc)

Re-arranges the tab control TC into the rectangle rc (a RECT Memory). It is intended for use inside OnArrange.


2. Creating Objects

Member Description
te.Object() An empty object
te.Array() An array object
te.FolderItems([DataObject]) Creates a FolderItems. If you pass an IDataObject (or a FolderItems) as the argument, it is created with that content
te.CommonDialog A CommonDialog object (a new one is created each time te.CommonDialog is referenced; the Open/Save dialog and so on)
te.ProgressDialog A ProgressDialog object (the progress dialog)
te.WICBitmap A WICBitmap (image processing) object. The old name te.GdiplusBitmap is the same (deprecated)
te.WindowsAPI The api object (api Reference)
te.WindowsAPI0 A lightweight object that has only CreateObject. te.WindowsAPI0.CreateObject("api") gets api (used in asynchronous scripts)

Other than the api object, please basically use api.CreateObject(...).

Object kind Description
api.CreateObject("Array") An array object
api.CreateObject("CommonDialog") A CommonDialog object (a new one is created on each reference; the Open/Save dialog and so on)
api.CreateObject("Enum") An enumerator object
api.CreateObject("FolderItems") A FolderItems object
api.CreateObject("Object") An empty object
api.CreateObject("ProgressDialog") A ProgressDialog object (the progress dialog)
api.CreateObject("SafeArray", [object]) A SafeArray object
api.CreateObject("WICBitmap") A WICBitmap (image processing) object

te.CreateObject(progid)

Creates a new COM object (equivalent to new ActiveXObject). Returns empty on failure.

For this one too, please use api.CreateObject(progid).

const wsh = api.CreateObject("WScript.Shell");
const fso = api.CreateObject("Scripting.FileSystemObject");

te.GetObject(progid | moniker)

Gets a running COM object. If none is running, a new one is created, and if the argument is not a ProgID it is interpreted as a moniker (CoGetObject).

This is a different thing from api.GetObject(...).


3. Script-Wide Data

Member Read/Write Description
te.Data R/W A global variable that can hold any value. Shared between scripts (and within a range that does not span a reload)
te.Arguments R/W Writing stores a value, and reading returns the value and clears it (once only). For receiving the arguments passed with CreateCtrl(CTRL_SW, …)
te.hwnd R The handle of the main window
te.About R/W The application name and version string ("Tablacus Explorer …"). Passing a string overwrites it

te.Reload([bForce])

Reloads the settings (executed by a timer after 100 ms). Normally it clears the events and refreshes the screen. If the internal exception counter has run out, or if bForce is true, it performs a complete reload.

te.ClearEvents()

Clears all registered event handlers and also re-acquires the dark mode state. It is used in pre-reload processing.

te.AddEvent(name, proc) / te.RemoveEvent(name, proc)

Registers/unregisters a native function pointer (such as the return value of api.GetProcAddress). The targets are only the following three.

name Purpose
"GetArchive" A function of an archive extraction DLL
"GetImage" A function for getting images (thumbnails and so on)
"MessageSFVCB" A callback of the shell view

Registering a JavaScript function as an event (AddEvent("Name", function)) is a mechanism of the script side that sets the te.OnXxx properties (sync.js and others), and is a different thing from the core te.AddEvent.


4. Window and Drawing Control

te.LockUpdate([n]) / te.UnlockUpdate([n])

Suspends/resumes the recalculation of window layout (ArrangeWindow). The lock is counter based, and UnlockUpdate is needed as many times as you called it. With no argument, 16 is added to or subtracted from the internal counter (a full lock); with an argument, 1 is added or subtracted. UnlockUpdate with no argument re-runs the layout at the moment the lock is released.

te.LockUpdate();
try { /* operate on a large number of tabs or panes */ } finally { te.UnlockUpdate(); }

te.MainMenu(n)

Returns an HMENU that is a copy of the n-th submenu of the shell's main menu (the shell32 menu resource). If there is no current tab, the items are disabled. Discard it with api.DestroyMenu when you are done.


5. Numeric Setting Properties

Read with te.Xxx and write with te.Xxx = n (all of them are integers). Changing a value has the side effects below.

Property Description
te.Type Always read-only (returns CTRL_TE)
te.offsetLeft / offsetTop / offsetRight / offsetBottom The margins (px) of the control area inside the main window. Changing them re-arranges immediately
te.Tab A tab-related setting
te.CmdShow The display state at startup (SW_*)
te.Layout The layout setting. Changing it makes the layout and the view mode / icon size of all views be judged again
te.NetworkTimeout The timeout (ms) for checking whether a network path exists
te.SizeFormat The display format of file sizes
te.Version The version number
te.UseHiddenFilter Whether to use HiddenFilter
te.ColumnEmphasis Emphasized display of the sort column
te.ViewOrder The setting for the order of views
te.LibraryFilter The filter setting for libraries
te.AutoArrange The auto-arrange setting
te.ShowInternet The display setting of Internet (the "Internet" root)
te.DragIcon The setting of the icon during dragging

For many of these values, the detailed meaning (bit assignments and so on) is only stored by the implementation, and depends on how they are used in the settings screen (options.js) and sync.js.


6. String Setting Properties

Set them by passing an argument, and get them by passing none.

Property Description
te.DateTimeFormat The format of date-time columns
te.HiddenFilter The filter for hidden files (;-separated wildcards)
te.ExplorerBrowserFilter The filter for ExplorerBrowser
te.TreeHiddenFilter The filter for hiding items in the tree

7. Events (te.OnXxx)

You set a function in the form te.OnXxx = function (...) { ... } (it can also be read). In the implementation, these are slots that keep the function you set as it is and call it from the core. For the actual arguments and the meaning of return values, see the usage examples in script/sync.js / sync1.js / common.js or each add-on (the arguments below are listed only where they could be confirmed in the code).

View / navigation OnBeforeNavigate OnBeginNavigate OnNavigateComplete OnViewCreated OnViewModeChanged OnIconSizeChanged OnColumnsChanged OnColumnClick OnSort OnSorting OnFilterChanged OnFilterView OnContentsChanged OnIncludeItem OnILGetParent OnTranslatePath OnReplacePath OnGetPaneState OnVisibleChanged OnArrange

Item operations / drawing OnItemClick OnDefaultCommand OnItemPrePaint OnItemPostPaint OnHandleIcon OnHitTest OnSelectionChanged OnSelectionChanging OnBeginLabelEdit OnEndLabelEdit OnSetName OnGetAlt OnShowError

Input / menus / commands OnKeyMessage OnMouseMessage OnMenuMessage OnCommand OnInvokeCommand OnShowContextMenu

Drag and drop OnBeginDrag OnDragEnter OnDragOver OnDragLeave OnDrop OnDragImage - OnBeforeGetData(Ctrl, Items, nMode): Called when a drag ends (before the transfer, with the drop target not yet determined). In the implementation nMode = 4, and if the return value is true, the drag is cancelled

Application / system OnCreate OnClose OnAppMessage OnSystemMessage OnWindowRegistered (setting it starts subscribing to ShellWindows events) OnStatusText OnToolTip OnNewWindow OnClipboardText OnEndThread

Others Labels (the function that displays labels; if it has no call, it becomes "label mode") ColumnsReplace


8. Constants

These are the values returned by te.Ctrl() / te.Ctrls() / te.CreateCtrl() and by the Type of each object (defined globally in consts.js).

Constant Value Target
CTRL_FV 0 File view (ShellBrowser)
CTRL_SB 1 ShellBrowser
CTRL_EB 2 ExplorerBrowser
CTRL_TE 0x10000 te itself
CTRL_WB 0x20000 WebBrowser (main)
CTRL_SW 0x20001 WebBrowser (sub-window)
CTRL_AR 0x2ffff Array
CTRL_TC 0x30000 Tab control
CTRL_TV 0x40000 Tree view
CTRL_DT 0x80000 Desktop
CTRL_FI 0xF0000 FolderItems (enumeration)

9. Members of the Objects Returned by te.Ctrl

Member names only (extracted from each table definition). For details, see the implementation of each object (TE.cpp / objects.cpp).

ShellBrowser (CTRL_FV / CTRL_SB / CTRL_EB) Data hwnd Type Navigate Navigate2 Index FolderFlags History CurrentViewMode SetViewMode IconSize Options SizeFormat NameFormat ViewFlags Id FilterView Search FolderItem TreeView Parent Focus Close Title Suspend Items SelectedItems ShellFolderView Droptarget Columns GetColumns Searches MapColumnToSCID hwndList hwndView SortColumn GetSortColumn GroupBy HitTest hwndAlt AltSortColumn ItemCount Item Refresh ViewMenu TranslateAccelerator GetItemPosition SelectAndPositionItem SelectItem FocusedItem GetFocusedItem GetItemRect ViewProperty Notify NavigateComplete AddItem RemoveItem AddItems RemoveAll SessionId TotalFileSize ColumnsReplace OnIncludeObject AltSelectedItems VirtualName

TabCtrl (CTRL_TC) Data hwnd Type HitTest Move Selected Close SelectedIndex Visible Id LockUpdate UnlockUpdate SetOrder _NewEnum Item Count length Left Top Width Height Style Align TabWidth TabHeight

TreeView (CTRL_TV) Data Type hwnd Close hwndTree FolderView Align Visible Focus HitTest Refresh GetItemRect Notify Width Style EnumFlags RootStyle SelectedItem SelectedItems Root SetRoot Expand Columns CountViewTypes Depth EnumOptions Export Flags Import Mode ResetSort SetViewType Synchronize TVFlags

WebBrowser (CTRL_WB / CTRL_SW) Application Close Data Document DropMode Focus hwnd OnClose PreventClose TranslateAccelerator Type Visible Window

FolderItems (CTRL_FI, te.FolderItems(), api.DataObject()) _NewEnum AddItem Application Count Data dwEffect GetData hDrop Index Item length Parent pdwEffect SetData UseText

FolderItem _BLOB Alt Enum FocusedItem FolderItem Id Name Path Unavailable

Memory (api.Memory()) _BLOB _NewEnum Clone Count Free Item length P Read Size Write

ContextMenu (api.ContextMenu()) FolderView GetCommandString HandleMenuMsg hmenu idCmdFirst idCmdLast indexMenu InvokeCommand Items QueryContextMenu uFlags


10. Deprecated / Internal

Member Status
te.GdiplusBitmap The old name of te.WICBitmap. Deprecated
te.HookDragDrop Deprecated. Does nothing
te.Background / te.ThumbnailProvider Deprecated (already commented out)
te.TestObj Only in development builds (USE_TESTOBJECT)
te.fn An internal slot for synchronous scripts (_USE_SYNC build)