winUser module

Functions that wrap Windows API functions from user32.dll.

When working on this file, consider moving to winAPI.

winUser.CS_HREDRAW = 2

Redraws the entire window if a movement or size adjustment changes the width of the client area.

winUser.CS_VREDRAW = 1

Redraws the entire window if a movement or size adjustment changes the height of the client area.

class winUser.WNDCLASSEXW

Bases: Structure

_fields_ = [('cbSize', <class 'ctypes.c_ulong'>), ('style', <class 'ctypes.c_ulong'>), ('lpfnWndProc', <class 'ctypes.WINFUNCTYPE.<locals>.WinFunctionType'>), ('cbClsExtra', <class 'ctypes.c_long'>), ('cbWndExtra', <class 'ctypes.c_long'>), ('hInstance', <class 'ctypes.c_void_p'>), ('hIcon', <class 'ctypes.c_void_p'>), ('HCURSOR', <class 'ctypes.c_long'>), ('hbrBackground', <class 'ctypes.c_void_p'>), ('lpszMenuName', <class 'ctypes.c_wchar_p'>), ('lpszClassName', <class 'ctypes.c_wchar_p'>), ('hIconSm', <class 'ctypes.c_void_p'>)]
HCURSOR

Structure/Union member

cbClsExtra

Structure/Union member

cbSize

Structure/Union member

cbWndExtra

Structure/Union member

hIcon

Structure/Union member

hIconSm

Structure/Union member

hInstance

Structure/Union member

hbrBackground

Structure/Union member

lpfnWndProc

Structure/Union member

lpszClassName

Structure/Union member

lpszMenuName

Structure/Union member

style

Structure/Union member

class winUser.NMHdrStruct

Bases: Structure

_fields_ = [('hwndFrom', <class 'ctypes.c_void_p'>), ('idFrom', <class 'ctypes.c_ulong'>), ('code', <class 'ctypes.c_ulong'>)]
code

Structure/Union member

hwndFrom

Structure/Union member

idFrom

Structure/Union member

class winUser.GUITHREADINFO

Bases: Structure

_fields_ = [('cbSize', <class 'ctypes.c_ulong'>), ('flags', <class 'ctypes.c_ulong'>), ('hwndActive', <class 'ctypes.c_void_p'>), ('hwndFocus', <class 'ctypes.c_void_p'>), ('hwndCapture', <class 'ctypes.c_void_p'>), ('hwndMenuOwner', <class 'ctypes.c_void_p'>), ('hwndMoveSize', <class 'ctypes.c_void_p'>), ('hwndCaret', <class 'ctypes.c_void_p'>), ('rcCaret', <class 'ctypes.wintypes.RECT'>)]
cbSize

Structure/Union member

flags

Structure/Union member

hwndActive

Structure/Union member

hwndCapture

Structure/Union member

hwndCaret

Structure/Union member

hwndFocus

Structure/Union member

hwndMenuOwner

Structure/Union member

hwndMoveSize

Structure/Union member

rcCaret

Structure/Union member

winUser.GW_RESULT_NOT_FOUND = 0

When GetWindow returns 0, it means the window has not been found. For example the last window has been reached, or an error has occurred.

class winUser.MSGFLT(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntEnum

ALLOW = 1
DISALLOW = 2
RESET = 0
winUser.setSystemScreenReaderFlag(val)
winUser.getSystemScreenReaderFlag()
winUser.LOBYTE(word)
winUser.HIBYTE(word)
winUser.MAKEWORD(lo, hi)
winUser.LOWORD(long)
winUser.HIWORD(long)
winUser.GET_X_LPARAM(lp)
winUser.GET_Y_LPARAM(lp)
winUser.MAKELONG(lo, hi)
winUser.waitMessage()
winUser.getMessage(*args) int
winUser.translateMessage(*args)
winUser.dispatchMessage(*args)
winUser.peekMessage(*args)
winUser.registerWindowMessage(name)
winUser.getAsyncKeyState(v)
winUser.getKeyState(v)
winUser.isWindow(hwnd)
winUser.isDescendantWindow(parentHwnd, childHwnd)
winUser.getForegroundWindow() int
winUser.setForegroundWindow(hwnd)
winUser.setFocus(hwnd)
winUser.getDesktopWindow() int
winUser.getControlID(hwnd)
winUser.getClientRect(hwnd)
winUser.setWinEventHook(*args)
winUser.unhookWinEvent(*args)
winUser.sendMessage(hwnd, msg, param1, param2)
winUser.getWindowThreadProcessID(hwnd: int) Tuple[int, int]

Returns a tuple of (processID, threadID)

winUser.getClassName(window: int) str
winUser.keybd_event(*args)
winUser.mouse_event(*args)
winUser.getAncestor(hwnd, flags)
winUser.setCursorPos(x, y)
winUser.getCursorPos()
winUser.getCaretPos()
winUser.getTopWindow(hwnd)
winUser.getWindowText(hwnd)
winUser.getWindow(window, relation)
winUser.isWindowVisible(window)
winUser.isWindowEnabled(window)
winUser.getGUIThreadInfo(threadID)
winUser.getWindowStyle(hwnd)
winUser.getExtendedWindowStyle(hwnd)
winUser.setExtendedWindowStyle(hwnd, exstyle)
winUser.SetLayeredWindowAttributes(hwnd, key, alpha, flags)
winUser.getPreviousWindow(hwnd)
winUser.getKeyboardLayout(idThread=0)
winUser.RedrawWindow(hwnd, rcUpdate, rgnUpdate, flags)
winUser.getKeyNameText(scanCode, extended)
winUser.FindWindow(className, windowName)
winUser.MessageBox(hwnd, text, caption, type)
winUser.PostMessage(hwnd, msg, wParam, lParam)
winUser.VkKeyScanEx(ch, hkl)
winUser.ScreenToClient(hwnd, x, y)
winUser.ClientToScreen(hwnd, x, y)
winUser.NotifyWinEvent(event, hwnd, idObject, idChild)
class winUser.STICKYKEYS(**kwargs)

Bases: Structure

_fields_ = (('cbSize', <class 'ctypes.c_ulong'>), ('dwFlags', <class 'ctypes.c_ulong'>))
cbSize

Structure/Union member

dwFlags

Structure/Union member

winUser.getSystemStickyKeys()
class winUser.KeyBdInput

Bases: Structure

_fields_ = [('wVk', <class 'ctypes.c_ushort'>), ('wScan', <class 'ctypes.c_ushort'>), ('dwFlags', <class 'ctypes.c_ulong'>), ('time', <class 'ctypes.c_ulong'>), ('dwExtraInfo', <class 'ctypes.wintypes.LP_c_ulong'>)]
dwExtraInfo

Structure/Union member

dwFlags

Structure/Union member

time

Structure/Union member

wScan

Structure/Union member

wVk

Structure/Union member

class winUser.HardwareInput

Bases: Structure

_fields_ = [('uMsg', <class 'ctypes.c_ulong'>), ('wParamL', <class 'ctypes.c_short'>), ('wParamH', <class 'ctypes.c_ushort'>)]
uMsg

Structure/Union member

wParamH

Structure/Union member

wParamL

Structure/Union member

class winUser.MouseInput

Bases: Structure

_fields_ = [('dx', <class 'ctypes.c_long'>), ('dy', <class 'ctypes.c_long'>), ('mouseData', <class 'ctypes.c_ulong'>), ('dwFlags', <class 'ctypes.c_ulong'>), ('time', <class 'ctypes.c_ulong'>), ('dwExtraInfo', <class 'ctypes.wintypes.LP_c_ulong'>)]
dwExtraInfo

Structure/Union member

dwFlags

Structure/Union member

dx

Structure/Union member

dy

Structure/Union member

mouseData

Structure/Union member

time

Structure/Union member

class winUser.Input_I

Bases: Union

_fields_ = [('ki', <class 'winUser.KeyBdInput'>), ('mi', <class 'winUser.MouseInput'>), ('hi', <class 'winUser.HardwareInput'>)]
hi

Structure/Union member

ki

Structure/Union member

mi

Structure/Union member

class winUser.Input

Bases: Structure

_fields_ = [('type', <class 'ctypes.c_ulong'>), ('ii', <class 'winUser.Input_I'>)]
ii

Structure/Union member

type

Structure/Union member

winUser.SendInput(inputs)
class winUser.PAINTSTRUCT

Bases: Structure

_fields_ = [('hdc', <class 'ctypes.c_long'>), ('fErase', <class 'ctypes.c_long'>), ('rcPaint', <class 'ctypes.wintypes.RECT'>), ('fRestore', <class 'ctypes.c_long'>), ('fIncUpdate', <class 'ctypes.c_long'>), ('rgbReserved', <class 'winUser.c_char_Array_32'>)]
fErase

Structure/Union member

fIncUpdate

Structure/Union member

fRestore

Structure/Union member

hdc

Structure/Union member

rcPaint

Structure/Union member

rgbReserved

Structure/Union member

winUser.paint(hwnd, painStruct=None)

Context manager that wraps BeginPaint and EndPaint. @param painStruct: The paint structure used in the call to BeginPaint.

if C{None} (default), an empty structure is provided.

class winUser.WinTimer(hwnd, idEvent, elapse, timerFunc=None)

Bases: object

Object that wraps the SetTimer function in user32. The timer is automatically destroyed using KillTimer when the object is terminated using L{terminate}.

Constructor

See https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-settimer for a description of the parameters.

terminate()

Terminates the timer. This should be called from the thread that initiated the timer.

winUser.openClipboard(hwndOwner=None)

A context manager version of OpenClipboard from user32. Use as the expression of a ‘with’ statement, and CloseClipboard will automatically be called at the end.

winUser.emptyClipboard()
winUser.getClipboardData(format)
winUser.setClipboardData(format, data)