diff --git a/stubs/pywin32/win32/win32api.pyi b/stubs/pywin32/win32/win32api.pyi index 6856c263c1f2..28941dbdbb90 100644 --- a/stubs/pywin32/win32/win32api.pyi +++ b/stubs/pywin32/win32/win32api.pyi @@ -1,17 +1,19 @@ from _typeshed import Incomplete, ReadableBuffer from collections.abc import Callable, Iterable -from typing import TypedDict +from typing import Literal, TypedDict, overload, type_check_only from typing_extensions import deprecated import _win32typing from win32.lib.pywintypes import TimeType, error as error +@type_check_only class _MonitorInfo(TypedDict): Monitor: tuple[int, int, int, int] Work: tuple[int, int, int, int] Flags: int Device: str +@type_check_only class _FileVersionInfo(TypedDict): Signature: int StrucVersion: int @@ -26,6 +28,43 @@ class _FileVersionInfo(TypedDict): FileSubtype: int FileDate: None | Incomplete +@type_check_only +class _PwrCapabilitiesBatteryScale(TypedDict): + Granularity: int + Capacity: int + +@type_check_only +class _PwrCapabilities(TypedDict): + PowerButtonPresent: bool + SleepButtonPresent: bool + LidPresent: bool + SystemS1: bool + SystemS2: bool + SystemS3: bool + SystemS4: bool + SystemS5: bool + HiberFilePresent: bool + FullWake: bool + VideoDimPresent: bool + ApmPresent: bool + UpsPresent: bool + ThermalControl: bool + ProcessorThrottle: bool + ProcessorMinThrottle: int + ProcessorMaxThrottle: int + FastSystemS4: bool + spare2: Incomplete | None + DiskSpinDown: bool + spare3: Incomplete | None + SystemBatteriesPresent: bool + BatteriesAreShortTerm: bool + BatteryScale: tuple[_PwrCapabilitiesBatteryScale, ...] + AcOnLineWake: int + SoftLidWake: int + RtcWake: int + MinDeviceWakeState: int + DefaultLowLatencyWake: int + def AbortSystemShutdown(computerName: str, /) -> None: ... def InitiateSystemShutdown(computerName: str, message: str, timeOut, bForceClose, bRebootAfterShutdown, /) -> None: ... def Apply(exceptionHandler, func, args, /): ... @@ -71,79 +110,87 @@ def FormatMessageW( ) -> str: ... def FreeLibrary(hModule: int, /) -> None: ... def GenerateConsoleCtrlEvent(controlEvent: int, processGroupId: int, /) -> None: ... -def GetAsyncKeyState(key, /): ... +def GetAsyncKeyState(key: int, /) -> int: ... def GetCommandLine() -> str: ... def GetComputerName() -> str: ... -def GetComputerNameEx(NameType, /) -> str: ... -def GetComputerObjectName(NameFormat, /) -> str: ... +def GetComputerNameEx(NameType: int, /) -> str: ... +def GetComputerObjectName(NameFormat: int, /) -> str: ... def GetMonitorInfo(hMonitor: int) -> _MonitorInfo: ... def GetUserName() -> str: ... def GetUserNameEx(NameFormat: int, /) -> str: ... -def GetCursorPos() -> tuple[Incomplete, Incomplete]: ... -def GetCurrentThread(): ... -def GetCurrentThreadId(): ... -def GetCurrentProcessId(): ... +def GetCursorPos() -> tuple[int, int]: ... +def GetCurrentThread() -> int: ... +def GetCurrentThreadId() -> int: ... +def GetCurrentProcessId() -> int: ... def GetCurrentProcess() -> int: ... def GetConsoleTitle() -> str: ... -def GetDateFormat(locale, flags, time: TimeType, _format: str, /) -> str: ... -def GetDiskFreeSpace(rootPath: str, /): ... -def GetDiskFreeSpaceEx(rootPath: str, /) -> tuple[int, int, int]: ... +def GetDateFormat(locale: int, flags: int, time: TimeType | None, _format: str | None = None, /) -> str: ... +def GetDiskFreeSpace(rootPath: str | None = None, /) -> tuple[int, int, int, int]: ... +def GetDiskFreeSpaceEx(rootPath: str | None = None, /) -> tuple[int, int, int]: ... def GetDllDirectory() -> str: ... def GetDomainName() -> str: ... -def GetEnvironmentVariable(variable, /): ... -def GetEnvironmentVariableW(Name, /) -> str: ... -def GetFileAttributes(pathName: str, /): ... +def GetEnvironmentVariable(variable: str, /) -> str | None: ... +def GetEnvironmentVariableW(Name: str, /) -> str | None: ... +def GetFileAttributes(pathName: str, /) -> int: ... def GetFileVersionInfo(Filename: str, SubBlock: str, /) -> _FileVersionInfo: ... def GetFocus(): ... def GetFullPathName(fileName: str, /) -> str: ... def GetHandleInformation(Object: int, /): ... -def GetKeyboardLayout(threadId: int = ..., /): ... -def GetKeyboardLayoutName(): ... -def GetKeyboardState() -> str: ... -def GetKeyState(key, /): ... -def GetLastError(): ... -def GetLastInputInfo(): ... -def GetLocalTime(): ... +def GetKeyboardLayout(threadId: int = ..., /) -> int: ... +def GetKeyboardLayoutName() -> str: ... +def GetKeyboardState() -> bytes: ... +def GetKeyState(key: int, /) -> int: ... +def GetLastError() -> int: ... +def GetLastInputInfo() -> int: ... +def GetLocalTime() -> tuple[int, int, int, int, int, int, int, int]: ... def GetLongPathName(fileName: str, /) -> str: ... def GetLongPathNameW(fileName: str, /) -> str: ... -def GetLogicalDrives(): ... +def GetLogicalDrives() -> int: ... def GetLogicalDriveStrings() -> str: ... -def GetModuleFileName(hModule: int, /) -> str: ... -def GetModuleFileNameW(hModule: int, /) -> str: ... -def GetModuleHandle(fileName: str | None = ..., /) -> int: ... -def GetPwrCapabilities(): ... +def GetModuleFileName(hModule: int | None, /) -> str: ... +def GetModuleFileNameW(hModule: int | None, /) -> str: ... +def GetModuleHandle(fileName: str | None = None, /) -> int: ... +def GetPwrCapabilities() -> _PwrCapabilities: ... @deprecated("This function is obsolete, applications should use the registry instead.") -def GetProfileSection(section: str, iniName: str | None = ..., /): ... +def GetProfileSection(section: str, iniName: str | None = ..., /) -> list[Incomplete]: ... def GetProcAddress(hModule: int, functionName: _win32typing.PyResourceId, /): ... @deprecated("This function is obsolete, applications should use the registry instead.") def GetProfileVal(section: str, entry: str, defValue: str, iniName: str | None = ..., /) -> str: ... def GetShortPathName(path: str, /) -> str: ... -def GetStdHandle(handle: int, /) -> _win32typing.PyHANDLE: ... +def GetStdHandle(handle: int, /) -> int: ... def GetSysColor(index: int, /) -> int: ... -def GetSystemDefaultLangID(): ... -def GetSystemDefaultLCID(): ... +def GetSystemDefaultLangID() -> int: ... +def GetSystemDefaultLCID() -> int: ... def GetSystemDirectory() -> str: ... -def GetSystemFileCacheSize(): ... -def SetSystemFileCacheSize(MinimumFileCacheSize, MaximumFileCacheSize, Flags=...) -> None: ... -def GetSystemInfo(): ... -def GetNativeSystemInfo(): ... +def GetSystemFileCacheSize() -> tuple[int, int, int]: ... +def SetSystemFileCacheSize(MinimumFileCacheSize: int, MaximumFileCacheSize: int, Flags: int = ...) -> None: ... +def GetSystemInfo() -> tuple[int, int, int, int, int, int, int, int, tuple[int, int]]: ... +def GetNativeSystemInfo() -> tuple[int, int, int, int, int, int, int, int, tuple[int, int]]: ... def GetSystemMetrics(index: int, /) -> int: ... def GetSystemPowerStatus() -> dict[str, int]: ... -def GetSystemTime(): ... -def GetTempFileName(path: str, prefix: str, nUnique, /): ... +def GetSystemTime() -> tuple[int, int, int, int, int, int, int, int]: ... +def GetTempFileName(path: str, prefix: str, nUnique: int = ..., /) -> tuple[str, int]: ... def GetTempPath() -> str: ... -def GetThreadLocale(): ... +def GetThreadLocale() -> int: ... def GetTickCount() -> int: ... -def GetTimeFormat(locale, flags, time: TimeType, _format: str, /) -> str: ... -def GetTimeZoneInformation(times_as_tuples: bool = ..., /): ... -def GetVersion(): ... -def GetVersionEx(_format: int = ..., /): ... -def GetVolumeInformation(path: str, /): ... +def GetTimeFormat(locale: int, flags: int, time: TimeType | None, _format: str, /) -> str: ... +@overload +def GetTimeZoneInformation( + times_as_tuples: Literal[True] = True, / +) -> tuple[ + int, + tuple[int, str, tuple[int, int, int, int, int, int, int, int], int, str, tuple[int, int, int, int, int, int, int, int], int], +]: ... +@overload +def GetTimeZoneInformation(times_as_tuples: Literal[False], /): ... +def GetVersion() -> int: ... +def GetVersionEx(_format: int = ..., /) -> tuple[int, int, int, int, str]: ... +def GetVolumeInformation(path: str, /) -> tuple[str, int, int, int, str]: ... def GetWindowsDirectory() -> str: ... def GetWindowLong(hwnd: int | None, offset: int, /) -> int: ... -def GetUserDefaultLangID(): ... -def GetUserDefaultLCID(): ... -def GlobalMemoryStatus(): ... +def GetUserDefaultLangID() -> int: ... +def GetUserDefaultLCID() -> int: ... +def GlobalMemoryStatus() -> dict[str, int]: ... def GlobalMemoryStatusEx() -> dict[str, int]: ... def keybd_event(bVk, bScan, dwFlags: int = ..., dwExtraInfo: int = ..., /) -> None: ... def mouse_event(dx, dy, dwData, dwFlags: int = ..., dwExtraInfo=..., /) -> None: ... @@ -268,7 +315,7 @@ def MAKELANGID(PrimaryLanguage, SubLanguage, /): ... def MAKEWORD(low, high, /): ... def MAKELONG(low, high, /): ... def CommandLineToArgv(*args): ... # incomplete -def GetKeyboardLayoutList(*args): ... # incomplete +def GetKeyboardLayoutList() -> tuple[int, int]: ... def MapVirtualKey(*args): ... # incomplete def MessageBoxEx(*args): ... # incomplete def OpenThread(*args): ... # incomplete