Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnumWindows() throws an exception if the callback returns False #2163

Open
sn260591 opened this issue Dec 31, 2023 · 5 comments
Open

EnumWindows() throws an exception if the callback returns False #2163

sn260591 opened this issue Dec 31, 2023 · 5 comments

Comments

@sn260591
Copy link

  • Expected behavior
    No exceptions.

  • Actual behavior
    Throwing an exception pywintypes.error: (126, 'EnumWindows', 'The specified module could not be found.')

  • Steps to reproduce the problem
    Run this code:

import win32gui

def enum_windows_proc(hwnd, extra):
    print(hwnd)
    return False

win32gui.EnumWindows(enum_windows_proc, None)
  • Version of Python and pywin32
    Python 3.11.7, pywin32 306
@CristiFati
Copy link
Contributor

Should be fixed by #2219.

@Avasam
Copy link
Collaborator

Avasam commented Jun 22, 2024

@CristiFati I tried with a wheel from the latest action: https://github.com/mhammond/pywin32/actions/runs/9586723045 (pywin32-306-cp39-cp39-win_amd64.whl) and this is still the result I get:

Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32gui
>>> win32gui.EnumDesktopWindows  # Just making sure I am using a build from main
<built-in function EnumDesktopWindows>
>>> def enum_windows_proc(hwnd, extra):
...     print(hwnd)
...     return False
...
>>> win32gui.EnumWindows(enum_windows_proc, None)
66112
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pywintypes.error: (126, 'EnumWindows', 'The specified module could not be found.')

@CristiFati
Copy link
Contributor

@Avasam: any way for me to get the .whl (to avoid local build)?

@Avasam
Copy link
Collaborator

Avasam commented Jun 22, 2024

@Avasam: any way for me to get the .whl (to avoid local build)?

In the link I shared, if you scroll down to "artefacts" there's a download button.
Here's all the successful CI build jobs that ran on main: https://github.com/mhammond/pywin32/actions/workflows/main.yml?query=branch%3Amain+is%3Asuccess

You can do the same by looking at actions from a PR.

@CristiFati
Copy link
Contributor

CristiFati commented Jun 22, 2024

I'm experiencing a funny problem. Investigating:
What does the following line output:

python -c "import win32api as wapi;print(wapi.GetLastError());wapi.SetLastError(0);print(wapi.GetLastError())"

What about if running each of the 4 lines separately in the interpreter console?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants