api Reference (api.xxxxx)
Reference for the functions of the api (= te.WindowsAPI) object, available to Tablacus Explorer scripts.
- For their actual meaning, also refer to the documentation of the corresponding Win32 API.
Usage
// In the main (sync) script: api can be used from the start
api.MessageBox(te.hwnd, "Hello", "TE", 0);
// In asynchronous scripts (ui.js / the WebView2 side), calls return a Promise, so await is needed
const api = await te.WindowsAPI0.CreateObject("api");
const s = await api.sprintf(32, "%d-%s", 1, "a");
api.XXXin this reference is case-sensitive (api.sprintf,api.base64_encode,api.keybd_event, and others are names that contain lowercase letters).- The minimum number of arguments is the "Required" column of the tables. With fewer arguments than that, the call is not made and the return value is empty.
- Even if an exception occurs, it is wrapped as a
WindowsAPIexception.
Argument and Return Value Conventions
| Notation | Meaning |
|---|---|
HWND HANDLE HDC HMENU … |
Pointer values (a number or a 64-bit integer). Pass the return value of te.hwnd, api.GetDC(), and so on as it is |
string |
A string. Functions that take a file path (CopyFile, CreateFile, FindFirstFile, and so on) may automatically add the \\?\ prefix needed for long paths |
bool |
The return value is a boolean. True on success |
ptr |
The return value is a pointer value (HWND/HANDLE and so on). 0 on failure |
RECT POINT SIZE MSG and so on |
Pass a Memory object created with api.Memory("RECT") (output arguments are also written back to it) |
FolderItem / Items |
A FolderItem, a FolderItems, a path string, an IDList array, and so on (converted automatically inside) |
data |
Anything that can be treated as a byte sequence, such as a string, a Memory, or a SafeArray (UI1) |
Structure names accepted by api.Memory(): BITMAP BSTR BYTE char CHOOSECOLOR CHOOSEFONT COPYDATASTRUCT DIBSECTION DRAWITEMSTRUCT DWORD EXCEPINFO FINDREPLACE FOLDERSETTINGS GUID GUITHREADINFO HANDLE HDITEM ICONINFO ICONMETRICS int KEYBDINPUT KEYSTATE LOGFONT LPWSTR LVBKIMAGE LVCOLUMN LVFINDINFO LVGROUP LVHITTESTINFO LVITEM MEASUREITEMSTRUCT MENUINFO MENUITEMINFO MONITORINFOEX MOUSEINPUT MSG NMCUSTOMDRAW NMHDR NMLVCUSTOMDRAW NMTVCUSTOMDRAW NONCLIENTMETRICS NOTIFYICONDATA OSVERSIONINFO OSVERSIONINFOEX PAINTSTRUCT POINT RECT SECURITY_ATTRIBUTES SHELLEXECUTEINFO SHFILEINFO SHFILEOPSTRUCT SIZE TCHITTESTINFO TCITEM TOOLINFO TVHITTESTINFO TVITEM VARIANT WCHAR WIN32_FIND_DATA WORD
Table of Contents
- Objects and Data
- 64-bit Integers
- Strings, Encoding, and Cryptography
- Files and Paths
- Shell (FolderItem/IDList)
- Processes, Threads, and Synchronization
- Windows, Messages, and Input
- Menus
- GDI, Drawing, and Icons
- ImageList
- Others
Objects and Data
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
Array |
- | 0 | object | Returns an empty array object (equivalent to te.Array). |
CreateObject |
string |
1 | object | (see above) |
DataObject |
- | 0 | object | Returns an empty FolderItems (an IDataObject). |
DllGetClassObject |
dllpath, CLSID |
2 | object | Loads a DLL directly and creates a class object through DllGetClassObject. |
ExecMethod |
obj, method, Array(args) |
3 | - | Calls a method of an object by name, using the arguments passed as an array (by-reference arguments are written back to the array). |
ExecScript |
script, lang, [arg], [bAsync] |
2 | int / ptr | Runs a script. If the 4th argument is true, it runs on a separate thread and returns the thread handle. Normally the return value is an error code. |
GetDispatch |
obj, name |
2 | object | Gets a method of an object as a function object. |
GetProcAddress |
hModule, name / ordinal |
2 | - | Returns the address of a function in a module. The name is a string, or an ordinal. |
GetProcObject |
dllpath, name / ordinal, [arg] |
2 | object | Calls a GetProcObjectW-family function exported by a DLL and gets an object. |
GetScriptDispatch |
string, string |
2 | object | Parses a script string (the 2nd argument is the language) and returns an object that has its global namespace. |
Invoke |
func, [Array(args)] |
1 | - | Calls a function object. The arguments can be passed as an array. |
Memory |
type / size / SafeArray / IStream, [count / string], [ptr] |
1 | object | Creates a native memory block (a Memory object). The 1st argument is a structure name ("RECT", "POINT", "WCHAR", etc.), a byte size, a SafeArray, or an IStream. Passing a count or a string initializes it. |
ObjDelete |
obj, name |
2 | int | Deletes a property of an object. |
ObjDispId |
obj, name |
2 | int | Returns the DISPID of a property name (-1 if not found). |
Object |
- | 0 | object | Returns an empty object. |
ObjGetI |
obj, name |
2 | int64 | Gets a property/element of an object (case-insensitive). Date values are converted to UNIX epoch ms (a number). |
ObjPutI |
obj, name, value |
3 | int | Sets a property of an object (creating it if it does not exist). |
pvData |
SafeArray |
1 | ptr | Returns the pointer to the data area of a SafeArray. |
sizeof |
type / obj |
1 | int | Returns the byte size of a structure name or a Memory object. |
SysAllocString |
str / data, [codepage] |
1 | string | Creates a BSTR. If you pass a number as the 2nd argument, the byte sequence of the 1st argument is converted to a string with that code page. |
SysAllocStringByteLen |
str / data, len, [alt] |
2 | - | Creates a BSTR by specifying the byte length (for binary data). |
SysAllocStringLen |
str, len |
2 | - | Creates a BSTR by specifying the number of characters (the beginning is copied and the rest is uninitialized). |
SysStringByteLen |
str / data |
1 | int | Returns the byte length of a string / binary data. |
64-bit Integers
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
Add |
int64, int64 |
2 | int64 | Adds two values as 64-bit signed. |
HighPart |
int64 |
1 | int | The upper 32 bits of a 64-bit value. |
LowPart |
int64 |
1 | int | The lower 32 bits of a 64-bit value (signed). |
QuadPart |
DWORD, long |
1 | int64 | Builds a 64-bit integer from the lower DWORD and the upper LONG. With one argument, it returns the value as it is. |
ULowPart |
uint64 |
1 | uint64 | The lower 32 bits of a 64-bit value (unsigned). |
UQuadAdd |
int64, int64 |
2 | uint64 | 64-bit unsigned addition. |
UQuadCmp |
int64, int64 |
2 | int | 64-bit unsigned comparison (-1/0/1). |
UQuadPart |
DWORD, long |
1 | uint64 | The unsigned version of QuadPart. |
UQuadSub |
int64, int64 |
2 | int64 | 64-bit unsigned subtraction. |
Strings, Encoding, and Cryptography
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
base64_decode |
str, [bString] |
1 | - | Decodes Base64. If the 2nd argument is true, it returns a byte string (BSTR); if false/omitted, it returns a UI1 array. |
base64_encode |
data |
1 | string | Converts binary/string data to Base64. |
CommandLineToArgv |
cmdline, [Array] |
1 | object | Splits a command line string into an argument array. |
CRC32 |
data, [seed] |
1 | int | Returns the CRC32 of the data. The 2nd argument is the initial value. |
CryptProtectData |
data(string), entropy(string), [bArray] |
2 | - | Encrypts data with DPAPI (if the 3rd argument is true, a byte string). |
CryptUnprotectData |
data, entropy(string), [bArray] |
2 | - | Decrypts with DPAPI. |
FormatMessage |
[fmt], id, ... |
1 | string | Formats the system message of an error number, or a format string that contains %1 and the like. |
GetDateFormat |
lcid, flags, Date, format |
4 | string | Formats a date. |
GetLocaleInfo |
LCID, LCTYPE |
2 | string | Returns locale information (LCTYPE) as a string. |
GetTimeFormat |
lcid, flags, Date, format |
4 | string | Formats a time. |
GlobalAddAtom |
string |
1 | int | Adds a global atom. |
GlobalDeleteAtom |
ATOM |
1 | int | Deletes a global atom. |
GlobalFindAtom |
string |
1 | int | Searches for a global atom. |
GlobalGetAtomName |
ATOM |
1 | string | Gets the name of an atom. |
HashData |
data, cbHash |
2 | string | Returns the hash of the data (with the byte length specified) as a Base64 string. |
LoadString |
HINSTANCE, uint |
2 | string | Gets a resource string of a module. |
MultiByteToWideChar |
codepage, data, [len] |
2 | - | Converts a byte sequence to a string with the specified code page. |
PSFormatForDisplay |
propname, value, flags |
3 | string | Formats a property name and value into a string for Explorer-style display. |
PSGetDisplayName |
propname, [format] |
1 | - | Returns the display name of a property name (such as System.Size). |
RegisterWindowMessage |
string |
1 | int | Gets a registered window message ID. |
sprintf |
maxLen, format, ...values |
3 | string | Formats with a maximum length, a format, and values… (%d %s %f %x, etc.). |
sscanf |
str, format |
2 | int64 | Reads the first value from a string according to the format. |
StrCmpI |
string, string |
2 | int | Compares ignoring case. |
StrCmpLogical |
string, string |
2 | int | A comparison that takes numbers into account (Explorer order). |
StrCmpNI |
string, string, int |
3 | int | Compares the first n characters ignoring case. |
StrFormatByteSize |
size, [fmt] |
1 | string | Formats a number of bytes in the form "1.5 MB". |
StrLen |
string |
1 | int | The length of a string. |
WideCharToMultiByte |
codepage, str |
2 | - | Converts a string to a byte array (UI1) in the specified code page. |
Files and Paths
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
CloseHandle |
HANDLE |
1 | bool | Closes a handle. |
CopyFile |
string, string, bool |
3 | bool | Copies a file (3rd argument: whether to fail if the destination exists). |
CreateDirectory |
string, SECURITY_ATTRIBUTES |
1 | bool | Creates a directory. |
CreateFile |
string, DWORD, DWORD, SECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE |
7 | ptr | Gets a file handle (Win32 CreateFile). |
DeleteFile |
string |
1 | bool | Deletes a file. |
Extract |
arg0, arg1, string, string |
4 | int | Extracts an archive (a DLL such as 7-Zip). With a progress dialog. |
ExtractIconEx |
string, int, Memory(HICON), Memory(HICON), uint |
5 | int | Extracts icons from a file. |
FindClose |
HANDLE |
1 | bool | Closes a search handle. |
FindFirstFile |
string, WIN32_FIND_DATA |
2 | ptr | Starts a search. The path is automatically converted to the \\?\ extended form. |
FindNextFile |
HANDLE, WIN32_FIND_DATA |
2 | bool | Gets the next search result. |
FreeLibrary |
HMODULE, uint |
1 | bool | Frees a DLL. |
GetCurrentDirectory |
- | 0 | string | Returns the current directory. |
GetDiskFreeSpaceEx |
string |
1 | object | Returns an object that has FreeBytesOfAvailable, TotalNumberOfBytes, and TotalNumberOfFreeBytes. |
GetFileAttributes |
string |
1 | int | Gets the file attributes. |
GetFileVersionInfo |
string |
1 | string | Returns the file version a.b.c.d as a string. |
GetFinalPathNameByHandle |
HANDLE, DWORD |
2 | string | Gets the full path from a handle. |
GetModuleFileName |
HMODULE |
1 | string | Returns the path of a module. |
GetModuleHandle |
string |
1 | ptr | Returns a module handle. |
GetShortPathName |
string |
1 | string | Returns the short path name. |
LoadLibraryEx |
path, hFile, flags |
3 | ptr | Loads a DLL. |
mciSendString |
string, string, uint, HWND |
4 | int | Sends an MCI command. |
MoveFileEx |
string, string, DWORD |
3 | bool | Moves / renames a file. |
OutputDebugString |
string |
1 | - | Sends a string to the debug output. |
PathCreateFromUrl |
string |
1 | string | Converts a file:/// URL to a path. |
PathFileExists |
string |
1 | bool | Checks whether a path exists. |
PathIsDirectory |
string, DWORD, int |
1 | bool | Determines whether it is a directory. If you pass a callback as the 3rd or later argument, it works asynchronously. |
PathIsNetworkPath |
string |
1 | bool | Whether it is a network path. |
PathIsRoot |
string |
1 | bool | Whether it is a root. |
PathIsSameRoot |
string, string |
2 | bool | Whether they have the same root. |
PathMatchSpec |
string, string |
2 | bool | Whether it matches a wildcard (;-separated allowed). |
PathQuoteSpaces |
string |
1 | string | Encloses a path that contains spaces (or , &) in ". |
PathSearchAndQualify |
string |
1 | string | Fully qualifies a relative path using the search path. |
PathUnquoteSpaces |
string |
1 | string | Removes the leading and trailing ". |
PlaySound |
string, HMODULE, DWORD |
3 | bool | Plays a sound. |
ReadFile |
hFile / IStream, bytes |
2 | - | Reads the specified number of bytes from a file handle or an IStream and returns them as a byte string. |
ReplaceFile |
string, string, string, DWORD |
4 | bool | Replaces a file. |
SetCurrentDirectory |
string |
1 | bool | Sets the current directory. |
SetDllDirectory |
string |
1 | bool | Sets the DLL search directory. |
SetFileAttributes |
string, DWORD |
2 | bool | Sets the file attributes. |
SetFilePointer |
hFile / IStream, offset, method |
3 | int64 | Moves the position of a file/stream and returns the new position. |
SetFileTime |
path / Item, ctime, atime, mtime |
4 | bool | Sets the creation, access, and modification times of a file (pass Date objects). |
SHCreateStreamOnFileEx |
path, mode, attr, bCreate, [template], [Object(out)] |
4 | int | Creates an IStream object from a file. |
SHDefExtractIcon |
string, int, uint, Memory(HICON), Memory(HICON), uint |
6 | int | Extracts icons from a file (the Shell default). |
SHEmptyRecycleBin |
HWND, string, DWORD |
3 | int | Empties the Recycle Bin. |
SHFileOperation |
wFunc, from, to, flags, bAsync |
1 | - | Copies / moves / deletes files (FO_*). from/to are a string or an array. If the 5th argument is true, it runs on a separate thread. |
UrlCreateFromPath |
string |
1 | string | Converts a path to a file:/// URL. |
URLDownloadToFile |
pCaller, url, path, [reserved] |
3 | int | Saves a URL (a data: URI, an XHR object, or an IStream is also allowed) to a file. |
WriteFile |
hFile / IStream, data |
2 | int | Writes to a file handle or an IStream. |
Shell (FolderItem/IDList)
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
AssocQueryString |
flags, str, Item(FolderItem/Items), pszExtra |
4 | string | Gets the association information (ASSOCSTR) of a FolderItem. |
CompareIDs |
lParam, Item1, Item2 |
3 | int | Compares with IShellFolder::CompareIDs. |
ContextMenu |
CLSID/DLLpath, ..., Item, Items, hKey, subkey, [Unknown] |
1 | - | Creates a context menu object from a shell extension (IShellExtInit). |
DoDragDrop |
Items, dwEffect, [Object] |
2 | int | Starts drag and drop. |
DropTarget |
Item |
1 | object | Returns the IDropTarget of a FolderItem. |
GetAttributesOf |
Items, SFGAO |
2 | int | Returns the SFGAO attributes of FolderItem(s) (only the specified bits). |
GetDisplayNameOf |
Item, SHGDN flags |
2 | - | Returns the display name of a FolderItem (specified with SHGDN_*). |
HasThumbnail |
Item |
1 | int | Whether a thumbnail is available. Bit 1 = IThumbnailProvider, bit 2 = IExtractImage. |
ILClone |
Item |
1 | object | Duplicates (normalizes) a FolderItem. |
ILCreateFromPath |
path, [bArray] |
1 | object | Creates a FolderItem from a path. If the 2nd argument is true, it returns an IDList byte array. |
ILFindLastID |
Item |
1 | FolderItem | Returns the IDList that holds the last ID. |
ILGetCount |
Item |
1 | int | The number of levels in an IDList. |
ILGetParent |
Item |
1 | object | Returns the FolderItem of the parent folder. |
ILIsEmpty |
Item |
1 | bool | Whether it is the desktop (root). |
ILIsEqual |
Item1, Item2 |
2 | bool | Whether two FolderItems are equal. |
ILIsParent |
Item1, Item2, bImmediate |
3 | bool | Whether the first is a parent of the second (3rd argument: whether only the direct parent counts). |
ILRemoveLastID |
Item |
1 | FolderItem | Returns the FolderItem with the last ID removed. |
SHChangeNotification_Lock |
hMem, pid, Object(out) |
3 | object | Extracts the data of a notification message and stores it in Object. |
SHChangeNotification_Unlock |
- | 1 | bool | (For compatibility) always true. |
SHChangeNotify |
event, flags, item1, item2 |
4 | - | Issues a shell change notification. |
SHChangeNotifyDeregister |
ulong |
1 | bool | Unregisters a notification registration. |
SHChangeNotifyRegister |
hwnd, source, event, msg, Item, bRecursive |
6 | int | Registers for shell change notifications. |
SHDoDragDrop |
hwnd, Items, Ctrl, dwEffect, [Object], bFlag |
4 | int | Starts drag and drop with a window specified. |
Shell_NotifyIcon |
DWORD, NOTIFYICONDATA |
2 | bool | Operates on a notification area icon. |
ShellExecute |
hwnd, verb, file, params, dir, nShow |
6 | ptr | Calls ShellExecute. |
ShellExecuteEx |
SHELLEXECUTEINFO |
1 | bool | Calls ShellExecuteEx. |
SHFreeNameMappings |
HANDLE |
1 | - | Frees name mappings. |
SHFreeShared |
HANDLE, DWORD |
2 | bool | Frees shared memory. |
SHGetDataFromIDList |
Item, nFormat, pv, cb |
4 | int | Gets data (SHGDFIL_*) from an IDList. |
SHGetFileInfo |
path / Item, attr, SHFILEINFO, cb, flags |
5 | ptr | Gets information about a file/IDList (icon, type, and so on). |
SHGetImageList |
int |
1 | ptr | Gets a system image list. |
SHParseDisplayName |
- | 3 | - | Parses a display name/path into a FolderItem (supports asynchronous calls). |
ShRunDialog |
HWND, HICON, string, string, string, DWORD |
6 | - | Shows the "Run" dialog. |
SHSimpleIDListFromPath |
path, attr, [date], size |
1 | FolderItem | Creates a simple IDList without querying the file system. |
SHTestTokenMembership |
HANDLE, ulong |
2 | bool | Checks the group membership of a token. |
Processes, Threads, and Synchronization
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
CreateEvent |
SECURITY_ATTRIBUTES, bool, bool, string |
4 | ptr | Creates an event object. |
CreateProcess |
cmdline, dir, codepage, timeout, [flags], [bObject] |
1 | string / object | Runs a command and returns its standard output as a string (using a pipe). Arguments: cmdline, dir, codepage (0 = auto, 1 = ANSI, 2 = Unicode), timeout (ms, 0 = infinite), flags, bObject. If bObject is true, {StdOut, ProcessId}. -1 on failure. |
DoEvents |
- | 0 | bool | Processes one pending message. True if something was processed. |
GetCommandLine |
- | 0 | - | Returns the command line string. |
GetCurrentProcess |
- | 0 | ptr | The pseudo handle of the current process. |
GetCurrentThreadId |
- | 0 | int | The current thread ID (the declared return type is bool, but the ID is stored in it). |
GetThreadCount |
[tid] |
0 | int | The number of running threads (of that thread, if a thread ID is passed). |
GetUserName |
- | 0 | string | Returns the user name. |
GetVersionEx |
OSVERSIONINFOEX |
1 | bool | Gets the OS version (OSVERSIONINFOEX). |
IsWow64Process |
HANDLE |
1 | bool | Whether it is running under WOW64. |
MsgWaitForMultipleObjectsEx |
DWORD, Memory(HANDLE[]), DWORD, DWORD, DWORD |
5 | int | Waits for multiple objects while processing messages. |
OpenProcess |
DWORD, bool, DWORD |
3 | ptr | Opens a process. |
ResetEvent |
HANDLE |
1 | bool | Sets an event to the non-signaled state. |
RunDLL |
HMODULE, WORD, HWND, HINSTANCE, string, int |
6 | - | Calls a DLL entry point (in the rundll32 form). |
SetEvent |
HANDLE |
1 | bool | Sets an event to the signaled state. |
Sleep |
DWORD |
1 | - | Waits for the specified number of milliseconds. |
WaitForInputIdle |
HANDLE, DWORD |
2 | int | Waits for a process to become idle for input. |
WaitForSingleObject |
HANDLE, DWORD |
2 | int | Waits for an object. |
Windows, Messages, and Input
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
AllowSetForegroundWindow |
DWORD |
1 | bool | Allows a process to become the foreground. |
BeginPaint |
HWND, PAINTSTRUCT |
2 | ptr | Starts painting. |
BringWindowToTop |
HWND |
1 | bool | Brings a window to the front. |
CallWindowProc |
WNDPROC, HWND, uint, WPARAM, LPARAM |
5 | ptr | Calls a window procedure. |
ChangeWindowMessageFilterEx |
HWND, uint, DWORD, CHANGEFILTERSTRUCT |
4 | bool | Changes the message filter. |
ChooseColor |
CHOOSECOLOR |
1 | bool | The color selection dialog. |
ChooseFont |
CHOOSEFONT |
1 | bool | The font selection dialog. |
ClientToScreen |
hwnd, pt(POINT) |
2 | bool | Client coordinates → screen coordinates (updates the POINT). |
CreateWindowEx |
DWORD, string, string, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, Memory/ptr |
12 | ptr | Creates a window. |
DestroyCursor |
HCURSOR |
2 | bool | Destroys a cursor. |
DestroyWindow |
HWND |
1 | bool | Destroys a window. |
DispatchMessage |
MSG |
1 | ptr | Dispatches a message. |
DragAcceptFiles |
HWND, bool |
2 | - | Sets whether file drops are accepted. |
DragFinish |
HDROP |
1 | - | Frees an HDROP. |
DragQueryFile |
HDROP, long |
2 | int | Gets a file path from an HDROP (-1 for the count). |
EnableWindow |
HWND, bool |
2 | bool | Switches between enabled and disabled. |
EndPaint |
HWND, PAINTSTRUCT |
2 | bool | Ends painting. |
FindReplace |
FINDREPLACE |
1 | ptr | The replace dialog. |
FindText |
FINDREPLACE |
1 | ptr | The find dialog. |
FindWindow |
string, string |
2 | ptr | Searches for a window by class name / title. |
FindWindowEx |
HWND, HWND, string, string |
4 | ptr | Searches for a child window. |
GetAsyncKeyState |
int |
1 | int | The asynchronous state of a key. |
GetCapture |
- | 0 | ptr | The window that has the capture. |
GetClassLongPtr |
HWND, int |
2 | ptr | Gets a class attribute. |
GetClassName |
hwnd / obj |
1 | string | The class name of a window, or the CLSID string of a COM object. |
GetClientRect |
HWND, RECT |
2 | bool | Gets the client rectangle. |
GetClipboardData |
- | 0 | string | Gets the text on the clipboard. |
GetCursorPos |
- | 0 | bool | Returns the cursor position. If you pass a POINT as the argument, it is stored there and a bool is returned. |
GetDeviceCaps |
HDC, int |
2 | int | Gets device capabilities. |
GetDpiForMonitor |
[hMonitor], [type] |
0 | POINT{x,y} | Returns the DPI of a monitor as {x,y}. |
GetFocus |
- | 0 | ptr | The window that has focus. |
GetForegroundWindow |
- | 0 | ptr | The foreground window. |
GetGUIThreadInfo |
DWORD, GUITHREADINFO |
2 | bool | Gets GUI thread information. |
GetKeyboardState |
Memory(BYTE[]) |
1 | bool | Gets the 256-byte key state. |
GetKeyNameText |
long |
1 | string | Returns the name of a key. |
GetKeyState |
int |
1 | int | The state of a key. |
GetMessage |
MSG, HWND, uint, uint |
4 | bool | Gets a message. |
GetMessagePos |
- | 0 | int | The cursor position at the time of the last message. |
GetMonitorInfo |
HMONITOR, MONITORINFOEX |
2 | bool | Gets monitor information. |
GetParent |
HWND |
1 | ptr | The parent window. |
GetProp |
HWND, string |
2 | ptr | Gets a window property. |
GetSysColor |
int |
1 | int | Gets a system color. |
GetSysColorBrush |
int |
1 | ptr | The brush of a system color. |
GetSystemMetrics |
int |
1 | int | Gets a system metric. |
GetTopWindow |
HWND |
1 | ptr | The topmost child window. |
GetWindow |
hwnd, cmd / obj |
1 | ptr | Returns a related window. If only a control object is passed as a hint, its hwnd is returned. |
GetWindowLongPtr |
HWND, int |
2 | ptr | Gets a window attribute. |
GetWindowRect |
HWND, RECT |
2 | bool | Gets the window rectangle (stored in the RECT). |
GetWindowText |
HWND |
1 | string | The window title (for the main window, the internal title). |
GetWindowThreadProcessId |
HWND, Memory(DWORD) |
2 | int | Returns the thread ID, and stores the process ID in the 2nd argument, a Memory (DWORD). |
ImmGetContext |
HWND |
1 | ptr | Gets the IME context. |
ImmGetVirtualKey |
HWND |
1 | int | Returns the virtual key from before IME processing. |
ImmReleaseContext |
HWND, HIMC |
2 | bool | Releases the IME context. |
ImmSetOpenStatus |
HIMC, bool |
2 | bool | Sets the open state of the IME. |
InvalidateRect |
HWND, RECT, bool |
3 | bool | Invalidates a region. |
IsAppThemed |
- | 0 | bool | Whether a theme is applied to the application. |
IsChild |
HWND, HWND |
2 | bool | Whether it is a child window. |
IsClipboardFormatAvailable |
uint |
1 | bool | Whether a clipboard format is available. |
IsIconic |
HWND |
1 | bool | Whether it is minimized. |
IsWindow |
HWND |
1 | bool | Whether it is a window. |
IsWindowEnabled |
HWND |
1 | bool | Whether it is enabled. |
IsWindowVisible |
HWND |
1 | bool | Whether it is visible. |
IsZoomed |
HWND |
1 | bool | Whether it is maximized. |
keybd_event |
BYTE, BYTE, DWORD, ULONG_PTR |
4 | - | Synthesizes a keyboard event. |
KillTimer |
HWND, UINT_PTR |
2 | bool | Deletes a timer. |
LoadCursor |
HINSTANCE |
2 | ptr | Loads a cursor. |
LoadCursorFromFile |
- | 2 | ptr | Loads a cursor from a file. |
MapVirtualKey |
uint, uint |
2 | int | Converts between virtual keys and scan codes and so on. |
MessageBox |
hwnd, text, title, flags, [Object] |
4 | int | Shows a message box. |
MonitorFromPoint |
arg0, DWORD |
2 | ptr | Gets a monitor from coordinates. |
MonitorFromRect |
RECT, DWORD |
2 | ptr | Gets a monitor from a rectangle. |
MonitorFromWindow |
HWND, DWORD |
2 | ptr | Gets a monitor from a window. |
mouse_event |
DWORD, DWORD, DWORD, DWORD, ULONG_PTR |
2 | - | Synthesizes a mouse event. |
MoveWindow |
hwnd, x, y, w, h, bRepaint |
6 | - | Moves and resizes a window. |
OleCmdExec |
obj, GUIDstring, cmdID, execopt, [in] |
5 | - | Executes a command through IOleCommandTarget. |
OleGetClipboard |
- | 0 | object | Gets the clipboard contents as a FolderItems. |
OleSetClipboard |
Items |
1 | int | Sets a FolderItems on the clipboard. |
OpenIcon |
HWND |
1 | bool | Restores from minimized. |
PeekMessage |
MSG, HWND, uint, uint, uint |
5 | bool | Checks for a message. |
PostMessage |
HWND, uint, WPARAM, LPARAM |
1 | - | Posts a message. |
RedrawWindow |
HWND, RECT, HRGN, uint |
4 | bool | Redraws. |
RegisterHotKey |
HWND, int, uint, uint |
4 | bool | Registers a hot key. |
ReleaseCapture |
- | 0 | bool | Releases the capture. |
ScreenToClient |
hwnd, pt(POINT) |
2 | bool | Screen coordinates → client coordinates. |
SendInput |
uint, INPUT, int |
3 | int | Synthesizes input. |
SendMessage |
HWND, uint, WPARAM, LPARAM |
2 | ptr | Sends a message. |
SendMessageTimeout |
hwnd, msg, wParam, lParam, flags, timeout, [Object(out)] |
6 | ptr | Sends with a timeout. The result is stored in Object[0] of the 7th argument. |
SendNotifyMessage |
HWND, uint, WPARAM, LPARAM |
4 | bool | Sends asynchronously. |
SetCapture |
HWND |
1 | ptr | Sets the mouse capture. |
SetClassLongPtr |
HWND, int, LONG_PTR |
3 | ptr | Sets a class attribute. |
SetClipboardData |
text |
1 | - | Sets text on the clipboard. |
SetCursor |
HCURSOR |
1 | ptr | Sets the cursor. |
SetCursorPos |
int, int |
2 | bool | Sets the cursor position. |
SetFocus |
- | 1 | - | Sets focus (for the main window, it activates the current view). |
SetForegroundWindow |
HWND |
1 | bool | Brings a window to the foreground. |
SetKeyboardState |
Memory(BYTE[]) |
1 | bool | Sets the key state. |
SetLayeredWindowAttributes |
HWND, COLORREF, BYTE, DWORD |
4 | bool | Sets the transparency of a layered window. |
SetSysColors |
n, Memory(int[]), Memory(COLORREF[]) |
3 | bool | Sets system colors. |
SetTimer |
HWND, UINT_PTR, uint |
3 | ptr | Sets a timer (no callback; received with WM_TIMER). |
SetWindowLongPtr |
HWND, int, LONG_PTR |
3 | ptr | Sets a window attribute. |
SetWindowPos |
HWND, HWND, int, int, int, int, uint |
7 | bool | Sets the position, size, and Z order. |
SetWindowText |
HWND, string |
2 | bool | Sets the title. |
SetWindowTheme |
hwnd, subAppName, subIdList |
3 | - | Sets the theme. If you pass darkmode_explorer / *itemsview for the hwnd of an Explorer view, internal theme handling is performed. |
ShouldAppsUseDarkMode |
- | 0 | bool | Whether dark mode is in use. |
ShowWindow |
HWND, int |
2 | bool | Changes the show state. |
SystemParametersInfo |
uint, uint, Memory/ptr, uint |
4 | bool | Gets/sets system parameters. |
TranslateMessage |
MSG |
1 | bool | Translates a message. |
UnregisterHotKey |
HWND, int |
2 | int | Unregisters a hot key. |
WindowFromPoint |
- | 1 | ptr | The window under the coordinates. |
Menus
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
CreateMenu |
- | 0 | - | Creates a menu (returned as a Menu object). |
CreatePopupMenu |
- | 0 | - | Creates a popup menu. |
DeleteMenu |
HMENU, uint, uint |
3 | bool | Deletes an item (a submenu is also destroyed). |
DestroyMenu |
HMENU |
1 | bool | Destroys a menu. |
EnableMenuItem |
HMENU, uint, uint |
3 | bool | Enables/disables an item. |
EndMenu |
- | 0 | bool | Closes the menu. |
GetMenuDefaultItem |
HMENU, uint, uint |
3 | int | The default item. |
GetMenuInfo |
HMENU, MENUINFO |
2 | bool | Gets menu information. |
GetMenuItemCount |
HMENU |
1 | int | The number of items. |
GetMenuItemID |
HMENU, int |
2 | int | The ID of an item. |
GetMenuItemInfo |
HMENU, uint, bool, MENUITEMINFO |
4 | bool | Gets item information. |
GetMenuItemRect |
HWND, HMENU, uint, RECT |
4 | bool | The rectangle of an item. |
GetMenuString |
HMENU, uint, long |
3 | string | The string of an item. |
GetSubMenu |
HMENU, int |
2 | ptr | Gets a submenu. |
GetSystemMenu |
HWND, bool |
2 | ptr | Gets the system menu. |
InsertMenu |
HMENU, uint, uint, UINT_PTR, string |
5 | bool | Inserts an item. |
InsertMenuItem |
HMENU, uint, bool, MENUITEMINFO |
4 | bool | Inserts an item with MENUITEMINFO. |
IsMenu |
HMENU |
1 | bool | Whether it is a menu. |
LoadMenu |
HINSTANCE |
2 | ptr | Loads a menu from a resource. |
MenuItemFromPoint |
HWND, HMENU, POINT |
3 | int | Returns the item at the coordinates. |
RemoveMenu |
HMENU, uint, uint |
3 | bool | Removes an item (a submenu is not destroyed). |
SetMenuDefaultItem |
HMENU, uint, uint |
3 | bool | Sets the default item. |
SetMenuInfo |
HMENU, MENUINFO |
2 | bool | Sets menu information. |
SetMenuItemBitmaps |
HMENU, uint, uint, HBITMAP, HBITMAP |
5 | bool | Sets the check bitmaps of an item. |
SetMenuItemInfo |
HMENU, uint, bool, MENUITEMINFO |
4 | bool | Sets item information. |
TrackPopupMenuEx |
hmenu, flags, x, y, hwnd, TPMPARAMS, [IContextMenu] |
6 | int | Shows a popup menu (if you pass an IContextMenu as the 7th argument, subclassing is performed). |
GDI, Drawing, and Icons
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
AlphaBlend |
HDC, int, int, int, int, HDC, int, int, int, int, long |
11 | bool | Alpha-blend transfer. |
BitBlt |
HDC, int, int, int, int, HDC, int, int, DWORD |
9 | bool | Bit-block transfer. |
CopyImage |
HANDLE, uint, int, int, uint |
5 | ptr | Duplicates an image. |
CreateCompatibleBitmap |
HDC, int, int |
3 | ptr | Creates a compatible bitmap. |
CreateCompatibleDC |
HDC |
1 | ptr | Creates a compatible DC. |
CreateFontIndirect |
LOGFONT |
1 | ptr | Creates a font (LOGFONT). |
CreateIconIndirect |
ICONINFO |
1 | ptr | Creates an icon (ICONINFO). |
CreatePen |
int, int, COLORREF |
3 | ptr | Creates a pen. |
CreateSolidBrush |
COLORREF |
1 | ptr | Creates a brush. |
DeleteDC |
HDC |
1 | bool | Deletes a DC. |
DeleteObject |
HGDIOBJ |
1 | bool | Deletes a GDI object. |
DestroyIcon |
HICON |
1 | bool | Destroys an icon. |
DrawIcon |
HDC, int, int, HICON |
4 | bool | Draws an icon. |
DrawIconEx |
HDC, int, int, HICON, int, int, uint, HBRUSH, uint |
9 | bool | Draws an icon with a specified size. |
DrawText |
hdc, text, n, RECT, flags |
5 | int | Draws text. |
FillRect |
HDC, RECT, HBRUSH, RGBQUAD(uint) |
3 | bool | Fills a rectangle. If the brush is 0, specify a color in the 0xAABBGGRR form (A is SourceConstantAlpha) as the 3rd argument to fill semi-transparently. |
GetDC |
HWND |
1 | ptr | Gets the DC of a window. |
GetGlyphIndices |
HDC, string, arg2, DWORD |
4 | int | Gets glyph indices. |
GetIconInfo |
HICON, ICONINFO |
2 | bool | Gets icon information. |
GetObject |
HANDLE, int, Memory/ptr |
3 | int | Gets GDI object information. |
GetPixel |
HDC, int, int |
3 | int | The color of a pixel. |
GetStockObject |
int |
1 | ptr | Gets a stock object. |
GetTextExtentPoint32 |
HDC, string, SIZE |
3 | bool | The drawn size of a string. |
GetWindowDC |
HWND |
1 | ptr | The DC of the whole window. |
LineTo |
HDC, int, int |
3 | bool | Draws a line. |
LoadIcon |
HINSTANCE |
2 | ptr | Loads an icon. |
LoadImage |
HINSTANCE, arg1, uint, int, int, uint |
6 | ptr | Loads an image. |
MoveToEx |
HDC, int, int, POINT |
4 | bool | Moves the pen position. |
PlgBlt |
HDC, POINT, HDC, int, int, int, int, HBITMAP, int, int |
10 | bool | Transfer to a parallelogram. |
Rectangle |
HDC, int, int, int, int |
5 | int | Draws a rectangle. |
ReleaseDC |
HWND, HDC |
2 | int | Releases a DC. |
RoundRect |
HDC, int, int, int, int, int, int |
7 | bool | Draws a rounded rectangle. |
SelectObject |
HDC, HGDIOBJ |
2 | ptr | Selects an object. |
SetBkColor |
HDC, COLORREF |
2 | int | Sets the background color. |
SetBkMode |
HDC, int |
2 | int | Sets the background mode. |
SetDCBrushColor |
HDC, COLORREF |
2 | int | Sets the DC brush color. |
SetDCPenColor |
HDC, COLORREF |
2 | int | Sets the DC pen color. |
SetRect |
rc(RECT), l, t, r, b |
1 | rc | Sets values into a RECT. |
SetTextColor |
HDC, COLORREF |
2 | int | Sets the text color. |
StretchBlt |
HDC, int, int, int, int, HDC, int, int, int, int, DWORD |
11 | bool | Scaling transfer (HALFTONE). |
TransparentBlt |
HDC, int, int, int, int, HDC, int, int, int, int, uint |
11 | bool | Transfer with a transparent color. |
ImageList
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
ImageList_Add |
HIMAGELIST, HBITMAP, HBITMAP |
3 | int | Adds a bitmap. |
ImageList_AddIcon |
HIMAGELIST, HICON |
2 | int | Adds an icon. |
ImageList_AddMasked |
HIMAGELIST, HBITMAP, COLORREF |
3 | int | Adds with a transparent color specified. |
ImageList_Copy |
HIMAGELIST, int, HIMAGELIST, int, uint |
5 | bool | Copies / swaps images. |
ImageList_Create |
int, int, uint, int, int |
5 | ptr | Creates an image list. |
ImageList_Destroy |
HIMAGELIST, bool |
1 | int | Destroys it (if the 2nd argument is true, a COM Release). |
ImageList_Draw |
HIMAGELIST, int, HDC, int, int, uint |
6 | bool | Draws. |
ImageList_DrawEx |
HIMAGELIST, int, HDC, int, int, int, int, COLORREF, COLORREF, uint |
10 | bool | Extended drawing. |
ImageList_Duplicate |
HIMAGELIST |
1 | ptr | Duplicates it. |
ImageList_GetBkColor |
HIMAGELIST |
1 | int | Gets the background color. |
ImageList_GetIcon |
HIMAGELIST, int, uint |
3 | ptr | Extracts an icon. |
ImageList_GetIconSize |
HIMAGELIST, SIZE |
2 | bool | Gets the icon size (stored in the SIZE). |
ImageList_GetImageCount |
HIMAGELIST |
1 | int | The number of images. |
ImageList_GetOverlayImage |
HIMAGELIST, int |
2 | int | The index of an overlay image. |
ImageList_LoadImage |
HINSTANCE, arg1, int, int, COLORREF, uint, uint |
7 | ptr | Loads from a resource/file. |
ImageList_Remove |
HIMAGELIST, int |
2 | bool | Removes an image. |
ImageList_Replace |
HIMAGELIST, int, HBITMAP, HBITMAP |
4 | int | Replaces an image. |
ImageList_ReplaceIcon |
HIMAGELIST, int, HICON |
3 | int | Replaces with / adds an icon. |
ImageList_SetBkColor |
HIMAGELIST, COLORREF |
2 | int | Sets the background color. |
ImageList_SetIconSize |
HIMAGELIST, int, int |
3 | bool | Sets the icon size. |
ImageList_SetImageCount |
HIMAGELIST, uint |
2 | bool | Sets the number of images. |
ImageList_SetOverlayImage |
HIMAGELIST, int, int |
3 | bool | Sets an overlay image. |
Others
| Function | Arguments | Required | Return value | Description |
|---|---|---|---|---|
CoTaskMemFree |
Memory/ptr |
1 | - | Frees memory allocated with CoTaskMemAlloc. |
Examples
// Run a child process and get its standard output
const out = api.CreateProcess('cmd /c dir C:\\', "C:\\", 0, 5000);
// Use a RECT
const rc = api.Memory("RECT");
api.GetWindowRect(te.hwnd, rc);
const w = rc.Right - rc.Left;
// File operations (FO_DELETE and the like are defined in consts.js)
api.SHFileOperation(FO_DELETE, "C:\\temp\\a.txt", null, FOF_SILENT | FOF_NOCONFIRMATION, false);
// Formatting
api.sprintf(32, "%05d", 42); // "00042"
// Getting a property dynamically
api.ObjGetI(obj, "length");