RAS Playground 日本語 GitHub

RAS standard library

Win32 API (win32)

Declarations for commonly used Win32 APIs. When you import them, as in import { Sleep } from "win32";, only the declarations you use are emitted, as Declare statements (#If VBA7) that work in both 32-bit and 64-bit Office. Functions in other DLLs can be declared yourself with declare module (specification §11).

import { Sleep } from "win32";

export function waitASecond() {
    Sleep(1000);
}

Reference

Function Sleep

function Sleep(dwMilliseconds: int): void

Suspends the current thread for the given number of milliseconds.

win32.ras

Function GetTickCount

function GetTickCount(): int

Milliseconds since the system started (wraps around after about 49.7 days).

win32.ras

Function GetTickCount64

function GetTickCount64(): long

Milliseconds since the system started (64-bit; 64-bit Office only).

win32.ras

Function GetCurrentProcessId

function GetCurrentProcessId(): int

The current process ID.

win32.ras

Function CopyMemory

@alias("RtlMoveMemory") export function CopyMemory(byref destination: any, byref source: any, length: ptr): void

Copies a block of memory (RtlMoveMemory).

win32.ras

Function QueryPerformanceCounter

function QueryPerformanceCounter(byref lpPerformanceCount: currency): int

Current value of the high-resolution performance counter.

win32.ras

Function QueryPerformanceFrequency

function QueryPerformanceFrequency(byref lpFrequency: currency): int

Frequency of the high-resolution performance counter.

win32.ras

Function GetForegroundWindow

function GetForegroundWindow(): ptr

Handle of the foreground window.

win32.ras

Function GetWindowText

@alias("GetWindowTextW") export function GetWindowText(hWnd: ptr, lpString: wstr, nMaxCount: int): int

Gets the title of a window.

win32.ras

Function FindWindow

@alias("FindWindowW") export function FindWindow(lpClassName: wstr, lpWindowName: wstr): ptr

Finds a window by class name and window name.

win32.ras

Function SetForegroundWindow

function SetForegroundWindow(hWnd: ptr): int

Brings a window to the foreground.

win32.ras

Function GetAsyncKeyState

function GetAsyncKeyState(vKey: int): short

Gets the state of a key.

win32.ras