From a46c48136bcbe9e8c1e5940f005174ee87ef7cdf Mon Sep 17 00:00:00 2001 From: Samuel T Date: Sun, 30 Oct 2022 19:04:37 -0400 Subject: [PATCH] pywin32 stubs update (#9040) boolean methods win32gui_struct MonitorFromRect, FindWindow, FindWindowEx, GetWindowPlacement, GetMenuItemRect --- stubs/pywin32/@tests/stubtest_allowlist.txt | 1 - stubs/pywin32/pythoncom.pyi | 2 +- stubs/pywin32/pythonwin/win32ui.pyi | 6 +- stubs/pywin32/win32/lib/win32gui_struct.pyi | 192 ++++++++++++++++++++ stubs/pywin32/win32/lib/winxptheme.pyi | 6 +- stubs/pywin32/win32/win32api.pyi | 2 +- stubs/pywin32/win32/win32clipboard.pyi | 2 +- stubs/pywin32/win32/win32gui.pyi | 24 ++- stubs/pywin32/win32/win32job.pyi | 2 +- stubs/pywin32/win32/win32process.pyi | 2 +- stubs/pywin32/win32/win32ras.pyi | 2 +- stubs/pywin32/win32/win32security.pyi | 2 +- stubs/pywin32/win32gui_struct.pyi | 1 + 13 files changed, 220 insertions(+), 24 deletions(-) create mode 100644 stubs/pywin32/win32/lib/win32gui_struct.pyi create mode 100644 stubs/pywin32/win32gui_struct.pyi diff --git a/stubs/pywin32/@tests/stubtest_allowlist.txt b/stubs/pywin32/@tests/stubtest_allowlist.txt index 5579b37d9..c56b31854 100644 --- a/stubs/pywin32/@tests/stubtest_allowlist.txt +++ b/stubs/pywin32/@tests/stubtest_allowlist.txt @@ -42,7 +42,6 @@ win32.lib.verstamp # Demos, tests and debugging win32.lib.pywin32_testutil win32.lib.rasutil -win32.lib.win32gui_struct win32com.demos.* win32com.servers.test_pycomtest win32com.test.* diff --git a/stubs/pywin32/pythoncom.pyi b/stubs/pywin32/pythoncom.pyi index 1c03b7600..690581bed 100644 --- a/stubs/pywin32/pythoncom.pyi +++ b/stubs/pywin32/pythoncom.pyi @@ -63,7 +63,7 @@ def GetRunningObjectTable(reserved: int = ...) -> _win32typing.PyIRunningObjectT def GetScodeString(scode) -> str: ... def GetScodeRangeString(scode) -> str: ... def GetSeverityString(scode) -> str: ... -def IsGatewayRegistered(iid: _win32typing.PyIID) -> bool: ... +def IsGatewayRegistered(__iid: _win32typing.PyIID | None) -> int: ... def LoadRegTypeLib(iid: _win32typing.PyIID, versionMajor, versionMinor, lcid) -> _win32typing.PyITypeLib: ... def LoadTypeLib(libFileName: str) -> _win32typing.PyITypeLib: ... def MakePyFactory(iid: _win32typing.PyIID) -> _win32typing.PyIClassFactory: ... diff --git a/stubs/pywin32/pythonwin/win32ui.pyi b/stubs/pywin32/pythonwin/win32ui.pyi index 59fb26186..61c3e6cee 100644 --- a/stubs/pywin32/pythonwin/win32ui.pyi +++ b/stubs/pywin32/pythonwin/win32ui.pyi @@ -110,9 +110,9 @@ def GetThread() -> _win32typing.PyCWinApp: ... def GetType(): ... def InitRichEdit() -> str: ... def InstallCallbackCaller(): ... -def IsDebug() -> bool: ... -def IsWin32s() -> bool: ... -def IsObject(o) -> bool: ... +def IsDebug() -> int: ... +def IsWin32s() -> int: ... +def IsObject(__o: object) -> bool: ... def LoadDialogResource(idRes, dll: _win32typing.PyDLL | None = ...): ... def LoadLibrary(fileName: str) -> _win32typing.PyDLL: ... def LoadMenu(_id, dll: _win32typing.PyDLL | None = ...) -> _win32typing.PyCMenu: ... diff --git a/stubs/pywin32/win32/lib/win32gui_struct.pyi b/stubs/pywin32/win32/lib/win32gui_struct.pyi new file mode 100644 index 000000000..362640797 --- /dev/null +++ b/stubs/pywin32/win32/lib/win32gui_struct.pyi @@ -0,0 +1,192 @@ +from _typeshed import Incomplete +from array import array + +is64bit: bool + +def UnpackWMNOTIFY(lparam) -> tuple[Incomplete, ...]: ... +def UnpackNMITEMACTIVATE(lparam) -> tuple[Incomplete, ...]: ... +def PackMENUITEMINFO( + fType: Incomplete | None = ..., + fState: Incomplete | None = ..., + wID: Incomplete | None = ..., + hSubMenu: Incomplete | None = ..., + hbmpChecked: Incomplete | None = ..., + hbmpUnchecked: Incomplete | None = ..., + dwItemData: Incomplete | None = ..., + text: Incomplete | None = ..., + hbmpItem: Incomplete | None = ..., + dwTypeData: Incomplete | None = ..., +) -> tuple[array[int], list[Incomplete]]: ... +def UnpackMENUITEMINFO( + s, +) -> tuple[ + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + str | None, + Incomplete | None, +]: ... +def EmptyMENUITEMINFO(mask: Incomplete | None = ..., text_buf_size: int = ...) -> tuple[array[int], list[Incomplete]]: ... +def PackMENUINFO( + dwStyle: Incomplete | None = ..., + cyMax: Incomplete | None = ..., + hbrBack: Incomplete | None = ..., + dwContextHelpID: Incomplete | None = ..., + dwMenuData: Incomplete | None = ..., + fMask: int = ..., +) -> array[int]: ... +def UnpackMENUINFO(s) -> tuple[Incomplete | None, Incomplete | None, Incomplete | None, Incomplete | None, Incomplete | None]: ... +def EmptyMENUINFO(mask: Incomplete | None = ...) -> array[int]: ... +def PackTVINSERTSTRUCT(parent, insertAfter, tvitem) -> tuple[bytes, list[Incomplete]]: ... +def PackTVITEM(hitem, state, stateMask, text, image, selimage, citems, param) -> tuple[array[int], list[Incomplete]]: ... +def EmptyTVITEM(hitem, mask: Incomplete | None = ..., text_buf_size: int = ...) -> tuple[array[int], list[Incomplete]]: ... +def UnpackTVITEM( + buffer, +) -> tuple[ + Incomplete, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, +]: ... +def UnpackTVNOTIFY( + lparam, +) -> tuple[ + Incomplete, + Incomplete, + Incomplete, + Incomplete, + tuple[ + Incomplete, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + ], + tuple[ + Incomplete, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + ], +]: ... +def UnpackTVDISPINFO( + lparam, +) -> tuple[ + Incomplete, + Incomplete, + Incomplete, + tuple[ + Incomplete, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + ], +]: ... +def PackLVITEM( + item: Incomplete | None = ..., + subItem: Incomplete | None = ..., + state: Incomplete | None = ..., + stateMask: Incomplete | None = ..., + text: Incomplete | None = ..., + image: Incomplete | None = ..., + param: Incomplete | None = ..., + indent: Incomplete | None = ..., +) -> tuple[array[int], list[Incomplete]]: ... +def UnpackLVITEM( + buffer, +) -> tuple[ + Incomplete, + Incomplete, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, +]: ... +def UnpackLVDISPINFO( + lparam, +) -> tuple[ + Incomplete, + Incomplete, + Incomplete, + tuple[ + Incomplete, + Incomplete, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + Incomplete | None, + ], +]: ... +def UnpackLVNOTIFY( + lparam, +) -> tuple[ + Incomplete, + Incomplete, + Incomplete, + Incomplete, + Incomplete, + Incomplete, + Incomplete, + Incomplete, + tuple[Incomplete, Incomplete], + Incomplete, +]: ... +def EmptyLVITEM( + item, subitem, mask: Incomplete | None = ..., text_buf_size: int = ... +) -> tuple[array[int], list[Incomplete]]: ... +def PackLVCOLUMN( + fmt: Incomplete | None = ..., + cx: Incomplete | None = ..., + text: Incomplete | None = ..., + subItem: Incomplete | None = ..., + image: Incomplete | None = ..., + order: Incomplete | None = ..., +) -> tuple[array[int], list[Incomplete]]: ... +def UnpackLVCOLUMN( + lparam, +) -> tuple[Incomplete | None, Incomplete | None, Incomplete | None, Incomplete | None, Incomplete | None, Incomplete | None]: ... +def EmptyLVCOLUMN(mask: Incomplete | None = ..., text_buf_size: int = ...) -> tuple[array[int], list[Incomplete]]: ... +def PackLVHITTEST(pt) -> tuple[array[int], None]: ... +def UnpackLVHITTEST(buf) -> tuple[tuple[Incomplete, Incomplete], Incomplete, Incomplete, Incomplete]: ... +def PackHDITEM( + cxy: Incomplete | None = ..., + text: Incomplete | None = ..., + hbm: Incomplete | None = ..., + fmt: Incomplete | None = ..., + param: Incomplete | None = ..., + image: Incomplete | None = ..., + order: Incomplete | None = ..., +) -> tuple[array[int], list[Incomplete]]: ... +def PackDEV_BROADCAST(devicetype, rest_fmt, rest_data, extra_data=...) -> bytes: ... +def PackDEV_BROADCAST_HANDLE(handle, hdevnotify: int = ..., guid=..., name_offset: int = ..., data=...) -> bytes: ... +def PackDEV_BROADCAST_VOLUME(unitmask, flags) -> bytes: ... +def PackDEV_BROADCAST_DEVICEINTERFACE(classguid, name: str = ...) -> bytes: ... + +class DEV_BROADCAST_INFO: + devicetype: Incomplete + def __init__(self, devicetype, **kw) -> None: ... + +def UnpackDEV_BROADCAST(lparam) -> DEV_BROADCAST_INFO | None: ... diff --git a/stubs/pywin32/win32/lib/winxptheme.pyi b/stubs/pywin32/win32/lib/winxptheme.pyi index df986476a..080eb5329 100644 --- a/stubs/pywin32/win32/lib/winxptheme.pyi +++ b/stubs/pywin32/win32/lib/winxptheme.pyi @@ -8,11 +8,11 @@ def DrawThemeText( ) -> None: ... def GetThemeBackgroundContentRect(hTheme: _win32typing.PyHTHEME, hdc, iPartId, iStateId, pBoundingRect): ... def GetThemeBackgroundExtent(hTheme: _win32typing.PyHTHEME, hdc, iPartId, iStateId, pContentRect): ... -def IsThemeActive() -> bool: ... -def IsAppThemed() -> bool: ... +def IsThemeActive() -> int: ... +def IsAppThemed() -> int: ... def GetWindowTheme(hwnd: int) -> _win32typing.PyHTHEME: ... def EnableThemeDialogTexture(hdlg, dwFlags) -> None: ... -def IsThemeDialogTextureEnabled(hdlg) -> bool: ... +def IsThemeDialogTextureEnabled(__hdlg: int | None) -> bool: ... def GetThemeAppProperties(): ... def EnableTheming(fEnable) -> None: ... def SetWindowTheme(hwnd: int, pszSubAppName: str, pszSubIdlist: str) -> None: ... diff --git a/stubs/pywin32/win32/win32api.pyi b/stubs/pywin32/win32/win32api.pyi index 2f7c21237..18b3eae74 100644 --- a/stubs/pywin32/win32/win32api.pyi +++ b/stubs/pywin32/win32/win32api.pyi @@ -124,7 +124,7 @@ def LoadString(handle: int, stringId, numChars: int = ...) -> str: ... def MessageBeep(arg): ... def MessageBox(hwnd: int, message: str, title: str, arg, arg1): ... def MonitorFromPoint(pt: tuple[Incomplete, Incomplete], Flags: int = ...) -> int: ... -def MonitorFromRect(rc: _win32typing.PyRECT, Flags: int = ...) -> int: ... +def MonitorFromRect(__rc: _win32typing.PyRECT | tuple[int, int, int, int], __Flags: int = ...) -> int: ... def MonitorFromWindow(hwnd: int, Flags: int = ...) -> int: ... def MoveFile(srcName: str, destName: str) -> None: ... def MoveFileEx(srcName: str, destName: str, flag) -> None: ... diff --git a/stubs/pywin32/win32/win32clipboard.pyi b/stubs/pywin32/win32/win32clipboard.pyi index 755e21283..5fbc2c402 100644 --- a/stubs/pywin32/win32/win32clipboard.pyi +++ b/stubs/pywin32/win32/win32clipboard.pyi @@ -14,7 +14,7 @@ def GetClipboardViewer(): ... def GetGlobalMemory(hglobal: int) -> str: ... def GetOpenClipboardWindow(): ... def GetPriorityClipboardFormat(formats): ... -def IsClipboardFormatAvailable(_format) -> bool: ... +def IsClipboardFormatAvailable(__format: int) -> int: ... def OpenClipboard(hWnd: int | None = ...): ... def RegisterClipboardFormat(name: str): ... def SetClipboardData(_format, hMem): ... diff --git a/stubs/pywin32/win32/win32gui.pyi b/stubs/pywin32/win32/win32gui.pyi index fa0decdf0..f5bc66644 100644 --- a/stubs/pywin32/win32/win32gui.pyi +++ b/stubs/pywin32/win32/win32gui.pyi @@ -61,7 +61,7 @@ def CreateAcceleratorTable(accels: tuple[tuple[Incomplete, Incomplete, Incomplet def LoadMenu(hinstance, resource_id: str): ... def DestroyMenu() -> None: ... def SetMenu(hwnd: int, hmenu) -> None: ... -def GetMenu() -> None: ... +def GetMenu(__hwnd: int) -> int: ... def LoadIcon(hinstance, resource_id: str): ... def CopyIcon(hicon): ... def DrawIcon(hDC, X, Y, hicon) -> None: ... @@ -101,8 +101,10 @@ def MessageBeep(_type) -> None: ... def CreateWindow(className: str, windowTitle: str, style, x, y, width, height, parent, menu, hinstance, reserved): ... def DestroyWindow(hwnd: int) -> None: ... def EnableWindow(hWnd: int, bEnable): ... -def FindWindow(ClassName: _win32typing.PyResourceId | None, WindowName: str) -> int: ... -def FindWindowEx(Parent: int, ChildAfter: int, ClassName: _win32typing.PyResourceId, WindowName: str) -> int: ... +def FindWindow(__ClassName: _win32typing.PyResourceId | str | None, __WindowName: str | None) -> int: ... +def FindWindowEx( + __Parent: int | None, __ChildAfter: int | None, __ClassName: _win32typing.PyResourceId | str, __WindowName: str +) -> int: ... def DragAcceptFiles(hwnd: int, fAccept) -> None: ... def DragDetect(hwnd: int, point: tuple[Incomplete, Incomplete]) -> None: ... def SetDoubleClickTime(newVal) -> None: ... @@ -112,8 +114,8 @@ def SetCaretPos(x, y) -> None: ... def GetCaretPos() -> tuple[Incomplete, Incomplete]: ... def ShowCaret(hWnd: int) -> None: ... def ShowWindow(hWnd: int, cmdShow): ... -def IsWindowVisible(hwnd: int) -> bool: ... -def IsWindowEnabled(hwnd: int) -> bool: ... +def IsWindowVisible(__hwnd: int | None) -> int: ... +def IsWindowEnabled(__hwnd: int | None) -> int: ... def SetFocus(hwnd: int) -> None: ... def GetFocus() -> None: ... def UpdateWindow(hwnd: int) -> None: ... @@ -137,7 +139,7 @@ def GetStockObject(Object) -> int: ... def PostQuitMessage(rc) -> None: ... def WaitMessage() -> None: ... def SetWindowPos(hWnd: int, InsertAfter: int, X, Y, cx, cy, Flags) -> None: ... -def GetWindowPlacement(): ... +def GetWindowPlacement(__hwnd: int) -> tuple[int, int, tuple[int, int], tuple[int, int], tuple[int, int, int, int]]: ... def SetWindowPlacement(hWnd: int, placement) -> None: ... def RegisterClass(wndClass: _win32typing.PyWNDCLASS): ... def UnregisterClass(atom: _win32typing.PyResourceId, hinst: int) -> None: ... @@ -200,7 +202,9 @@ def InsertMenuItem(hMenu, uItem, fByPosition, menuItem) -> None: ... def SetMenuItemInfo(hMenu, uItem, fByPosition, menuItem) -> None: ... def GetMenuItemInfo(hMenu, uItem, fByPosition, menuItem) -> None: ... def GetMenuItemCount(hMenu): ... -def GetMenuItemRect(hWnd: int, hMenu, uItem) -> tuple[int, int, int, int]: ... + +# Actually returns a list of int|tuple, but lists don't support positional types +def GetMenuItemRect(__hWnd: int | None, __hMenu: int | None, __uItem: int) -> tuple[int, tuple[int, int, int, int]]: ... def GetMenuState(hMenu, uID, flags): ... def SetMenuDefaultItem(hMenu, uItem, fByPos) -> None: ... def GetMenuDefaultItem(hMenu, fByPos, flags): ... @@ -322,9 +326,9 @@ def GetCursorPos() -> tuple[Incomplete, Incomplete]: ... def GetDesktopWindow(): ... def GetWindow(hWnd: int, uCmd): ... def GetWindowDC(hWnd: int) -> int: ... -def IsIconic(hWnd: int) -> bool: ... -def IsWindow(hWnd: int) -> bool: ... -def IsChild(hWndParent: int, hWnd: int) -> bool: ... +def IsIconic(__hWnd: int) -> int: ... +def IsWindow(__hWnd: int) -> int: ... +def IsChild(__hWndParent: int, hWnd: int) -> int: ... def ReleaseCapture() -> None: ... def GetCapture(): ... def SetCapture() -> None: ... diff --git a/stubs/pywin32/win32/win32job.pyi b/stubs/pywin32/win32/win32job.pyi index f7830a28a..2edda455b 100644 --- a/stubs/pywin32/win32/win32job.pyi +++ b/stubs/pywin32/win32/win32job.pyi @@ -6,7 +6,7 @@ def CreateJobObject(jobAttributes: _win32typing.PySECURITY_ATTRIBUTES, name) -> def OpenJobObject(desiredAccess, inheritHandles, name) -> None: ... def TerminateJobObject(hJob: int, exitCode) -> None: ... def UserHandleGrantAccess(hUserHandle: int, hJob: int, grant) -> None: ... -def IsProcessInJob(hProcess: int, hJob: int) -> bool: ... +def IsProcessInJob(__hProcess: int, __hJob: int): ... def QueryInformationJobObject(Job: int, JobObjectInfoClass): ... def SetInformationJobObject(Job: int, JobObjectInfoClass, JobObjectInfo) -> None: ... diff --git a/stubs/pywin32/win32/win32process.pyi b/stubs/pywin32/win32/win32process.pyi index e7eb8685f..7edafc70e 100644 --- a/stubs/pywin32/win32/win32process.pyi +++ b/stubs/pywin32/win32/win32process.pyi @@ -71,7 +71,7 @@ def SetProcessWorkingSetSize(hProcess: int, MinimumWorkingSetSize, MaximumWorkin def GetProcessShutdownParameters() -> tuple[Incomplete, Incomplete]: ... def SetProcessShutdownParameters(Level, Flags) -> None: ... def GetGuiResources(Process: int, Flags): ... -def IsWow64Process(Process: int | None = ...) -> bool: ... +def IsWow64Process(__Process: int | None = ...) -> bool: ... def ReadProcessMemory(*args, **kwargs): ... # incomplete def VirtualAllocEx(*args, **kwargs): ... # incomplete def VirtualFreeEx(*args, **kwargs): ... # incomplete diff --git a/stubs/pywin32/win32/win32ras.pyi b/stubs/pywin32/win32/win32ras.pyi index ad9f0a833..57be9a176 100644 --- a/stubs/pywin32/win32/win32ras.pyi +++ b/stubs/pywin32/win32/win32ras.pyi @@ -14,7 +14,7 @@ def GetEntryDialParams( ) -> tuple[Incomplete, Incomplete, Incomplete, Incomplete, Incomplete, Incomplete, Incomplete]: ... def GetErrorString(error) -> str: ... # noqa: F811 def HangUp(hras) -> None: ... -def IsHandleValid(hras) -> bool: ... +def IsHandleValid(__hras: int | None) -> bool: ... def SetEntryDialParams(fileName: str, RasDialParams, bSavePassword) -> None: ... def RASDIALEXTENSIONS(*args, **kwargs): ... # incomplete diff --git a/stubs/pywin32/win32/win32security.pyi b/stubs/pywin32/win32/win32security.pyi index 6469cd747..b391d28dc 100644 --- a/stubs/pywin32/win32/win32security.pyi +++ b/stubs/pywin32/win32/win32security.pyi @@ -31,7 +31,7 @@ def SECURITY_DESCRIPTOR() -> _win32typing.PySECURITY_DESCRIPTOR: ... def ImpersonateNamedPipeClient(handle) -> None: ... def ImpersonateLoggedOnUser(handle: int) -> None: ... def ImpersonateAnonymousToken(ThreadHandle: int) -> None: ... -def IsTokenRestricted(TokenHandle: int) -> bool: ... +def IsTokenRestricted(__TokenHandle: int | None) -> bool: ... def RevertToSelf() -> None: ... def LogonUser(Username: str, Domain: str, Password: str, LogonType, LogonProvider) -> int: ... def LogonUserEx( diff --git a/stubs/pywin32/win32gui_struct.pyi b/stubs/pywin32/win32gui_struct.pyi new file mode 100644 index 000000000..3c7cd0a8a --- /dev/null +++ b/stubs/pywin32/win32gui_struct.pyi @@ -0,0 +1 @@ +from win32.lib.win32gui_struct import *