diff --git a/stubs/pywin32/_win32typing.pyi b/stubs/pywin32/_win32typing.pyi index 54ed57dacaad..bb69b3ee40b9 100644 --- a/stubs/pywin32/_win32typing.pyi +++ b/stubs/pywin32/_win32typing.pyi @@ -1044,7 +1044,9 @@ class PyHANDLE: # type: ignore[type-var] def Close(self) -> None: ... def close(self) -> None: ... def Detach(self) -> Self: ... + def __bool__(self) -> bool: ... def __int__(self) -> int: ... + # PyHANDLE sets a lot more dunder methods, only to make them all raise with `TypeError: bad operand type` @final class PyHDESK: @@ -5279,7 +5281,7 @@ class PyCDocTemplate: ) -> None: ... def SetContainerInfo(self, _id, /) -> None: ... def SetDocStrings(self, docStrings: str, /) -> None: ... - def OpenDocumentFile(self, filename: str, bMakeVisible: int = ..., /) -> None: ... + def OpenDocumentFile(self, filename: str, bMakeVisible: int = ..., /) -> PyCDocument | None: ... class PyCDockContext: @property @@ -6009,7 +6011,7 @@ class PyCWinApp: def LoadOEMCursor(self, cursorId, /): ... def LoadIcon(self, idResource: int, /) -> int: ... def LoadStandardIcon(self, resourceName: PyResourceId, /): ... - def OpenDocumentFile(self, fileName: str, /) -> None: ... + def OpenDocumentFile(self, fileName: str, /) -> PyCDocument | None: ... def OnFileNew(self) -> None: ... def OnFileOpen(self) -> None: ... def RemoveDocTemplate(self, template: PyCDocTemplate | DocTemplate, /) -> None: ... diff --git a/stubs/pywin32/pythonwin/win32ui.pyi b/stubs/pywin32/pythonwin/win32ui.pyi index ea569a8dc85b..5523e7276879 100644 --- a/stubs/pywin32/pythonwin/win32ui.pyi +++ b/stubs/pywin32/pythonwin/win32ui.pyi @@ -97,7 +97,7 @@ def FullPath(path: str, /) -> str: ... def GetActiveWindow() -> _win32typing.PyCWnd: ... def GetApp() -> _win32typing.PyCWinApp: ... def GetAppName(): ... -def GetAppRegistryKey() -> None: ... +def GetAppRegistryKey() -> _win32typing.PyHKEY: ... def GetBytes(address, size, /) -> str: ... def GetCommandLine() -> str: ... def GetDeviceCaps(hdc, index, /): ... diff --git a/stubs/pywin32/win32/win32api.pyi b/stubs/pywin32/win32/win32api.pyi index 3a2185e29fd5..467a97fdc431 100644 --- a/stubs/pywin32/win32/win32api.pyi +++ b/stubs/pywin32/win32/win32api.pyi @@ -77,7 +77,12 @@ def CloseHandle(handle: int, /) -> None: ... def CopyFile(src, dest: str, bFailOnExist: int = ..., /) -> None: ... def DebugBreak() -> None: ... def DeleteFile(fileName: str, /) -> None: ... -def DragQueryFile(hDrop, fileNum: int = ..., /) -> str: ... + +@overload +def DragQueryFile(hDrop, fileNum: Literal[-1] = -1, /) -> int: ... # type: ignore[overload-overlap] +@overload +def DragQueryFile(hDrop, fileNum: int, /) -> str: ... + def DragFinish(hDrop, /) -> None: ... def DuplicateHandle( hSourceProcess: int, hSource: int, hTargetProcessHandle: int, desiredAccess: int, bInheritHandle: int, options: int, / diff --git a/stubs/pywin32/win32/win32event.pyi b/stubs/pywin32/win32/win32event.pyi index 91ea664f69a5..a79bb40f86b4 100644 --- a/stubs/pywin32/win32/win32event.pyi +++ b/stubs/pywin32/win32/win32event.pyi @@ -11,7 +11,7 @@ def CreateEvent( Name: str | None, /, ) -> int: ... -def CreateMutex(MutexAttributes: _win32typing.PySECURITY_ATTRIBUTES, InitialOwner, Name: str, /) -> int: ... +def CreateMutex(MutexAttributes: _win32typing.PySECURITY_ATTRIBUTES, InitialOwner, Name: str, /) -> _win32typing.PyHANDLE: ... def CreateSemaphore( SemaphoreAttributes: _win32typing.PySECURITY_ATTRIBUTES, InitialCount, MaximumCount, SemaphoreName, / ) -> int: ... diff --git a/stubs/pywin32/win32/win32gui.pyi b/stubs/pywin32/win32/win32gui.pyi index a002f39f78f2..34205f90d225 100644 --- a/stubs/pywin32/win32/win32gui.pyi +++ b/stubs/pywin32/win32/win32gui.pyi @@ -406,6 +406,10 @@ def IsChild(hWndParent: int, hWnd: int, /) -> int: ... def ReleaseCapture() -> None: ... def GetCapture(): ... def SetCapture() -> None: ... + +# Exists and is documented as a wrapper around TrackMouseEvent +# See https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-_trackmouseevent +def _TrackMouseEvent(tme: tuple[int, int, int], /) -> _win32typing.TRACKMOUSEEVENT: ... def ReleaseDC(hWnd: int | _win32typing.PyHANDLE | None, hDC: int | _win32typing.PyHANDLE | None, /) -> Literal[0, 1]: ... def CreateCaret(hWnd: int, hBitmap: _win32typing.PyGdiHANDLE, nWidth, nHeight, /) -> None: ... def DestroyCaret() -> None: ... diff --git a/stubs/pywin32/win32/win32pdh.pyi b/stubs/pywin32/win32/win32pdh.pyi index 15f5c1b70834..e70db79eb204 100644 --- a/stubs/pywin32/win32/win32pdh.pyi +++ b/stubs/pywin32/win32/win32pdh.pyi @@ -12,7 +12,7 @@ def OpenQuery(DataSource: Incomplete | None = ..., userData: int = ..., /): ... def CloseQuery(handle, /) -> None: ... def MakeCounterPath( elements: tuple[Incomplete, Incomplete, Incomplete, Incomplete, Incomplete, Incomplete], flags=..., / -) -> None: ... +) -> str: ... def GetCounterInfo(handle, bRetrieveExplainText, /) -> None: ... def GetFormattedCounterValue(handle, _format, /) -> tuple[Incomplete, Incomplete]: ... def CollectQueryData(hQuery, /) -> None: ... diff --git a/stubs/pywin32/win32comext/shell/shell.pyi b/stubs/pywin32/win32comext/shell/shell.pyi index 264d2a342f0b..b8da6a3cc76c 100644 --- a/stubs/pywin32/win32comext/shell/shell.pyi +++ b/stubs/pywin32/win32comext/shell/shell.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing import TypeAlias +from typing import Literal, TypeAlias, overload import _win32typing from win32.lib.pywintypes import com_error @@ -8,8 +8,17 @@ error: TypeAlias = com_error # noqa: Y042 def AssocCreate() -> _win32typing.PyIQueryAssociations: ... def AssocCreateForClasses() -> _win32typing.PyIUnknown: ... -def DragQueryFile(hglobal: int, index, /) -> str: ... -def DragQueryFileW(hglobal: int, index, /) -> str: ... + +@overload +def DragQueryFile(hglobal: int | _win32typing.PyHANDLE | None, index: Literal[-1] = -1, /) -> int: ... # type: ignore[overload-overlap] +@overload +def DragQueryFile(hglobal: int | _win32typing.PyHANDLE | None, index: int, /) -> str: ... + +@overload +def DragQueryFileW(hglobal: int | _win32typing.PyHANDLE | None, index: Literal[-1] = -1, /) -> int: ... # type: ignore[overload-overlap] +@overload +def DragQueryFileW(hglobal: int | _win32typing.PyHANDLE | None, index: int, /) -> str: ... + def DragQueryPoint(hglobal: int, /) -> tuple[Incomplete, Incomplete, Incomplete]: ... def IsUserAnAdmin() -> bool: ... def SHCreateDataObject(