Python Forum
MemoryError in pywinauto.findwindows.find_windows – Need Help!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MemoryError in pywinauto.findwindows.find_windows – Need Help!
#1
Hello everyone,

I've developed a Python application and distributed it to users.
Most of them are not experiencing any issues, but on some users' PCs, an error occurs with the following function:

# Code to find window handles for the program named 'ABC '
winhandle_list = pywinauto.findwindows.find_windows(title="ABC  ")  
The runtime error log saved in the logfile is as follows:
ERROR:root:Traceback (most recent call last):
  File "my_qt.py", line 952, in find_abc_windows
  File "pywinauto\findwindows.py", line 344, in find_windows
  File "pywinauto\findwindows.py", line 273, in find_elements
  File "pywinauto\findwindows.py", line 273, in <listcomp>
  File "pywinauto\win32_element_info.py", line 83, in rich_text
  File "pywinauto\handleprops.py", line 92, in text
  File "ctypes\__init__.py", line 297, in create_unicode_buffer
MemoryError
I authored only the my_qt.py file, and within it, the find_abc_windows() function calls ~~~.find_windows().

Since the code works on most users' PCs, I don't think the issue lies with my code,
but I'm stumped about where the problem might be or what I'm missing.

In my attempts to troubleshoot,
I learned that create_unicode_buffer is a function for allocating memory,
and the failure indicates a memory allocation issue.
However, this function doesn't usually require a lot of memory.

I wondered if it was a 32-bit vs. 64-bit issue,
so I checked and confirmed that my program was compiled with Python 64-bit, and the affected user's PC (i7 12th gen, 16GB RAM) also runs a 64-bit OS, so that doesn't seem to be the problem either.

Considering it might be an issue with the version of the Visual C++ Runtime Library,
I advised the user to uninstall their current library, install the latest version, and then reboot, but the error persists.

I've been at this for days and just can't seem to figure out what I'm missing.
Any guidance or suggestions would be greatly appreciated. Thank you!
Reply
#2
(Mar-25-2024, 02:23 AM)ktw3857 Wrote: Hello everyone,

I've developed a Python application and distributed it to users.
Most of them are not experiencing any issues, but on some users' PCs, an error occurs with the following function:

# Code to find window handles for the program named 'ABC '
winhandle_list = pywinauto.findwindows.find_windows(title="ABC  ")  
The runtime error log saved in the logfile is as follows:
ERROR:root:Traceback (most recent call last):
  File "my_qt.py", line 952, in find_abc_windows
  File "pywinauto\findwindows.py", line 344, in find_windows
  File "pywinauto\findwindows.py", line 273, in find_elements
  File "pywinauto\findwindows.py", line 273, in <listcomp>
  File "pywinauto\win32_element_info.py", line 83, in rich_text
  File "pywinauto\handleprops.py", line 92, in text
  File "ctypes\__init__.py", line 297, in create_unicode_buffer
MemoryError
I authored only the my_qt.py file, and within it, the find_abc_windows() function calls ~~~.find_windows().

Since the code works on most users' PCs, I don't think the issue lies with my code,
but I'm stumped about where the problem might be or what I'm missing.

In my attempts to troubleshoot,
I learned that create_unicode_buffer is a function for allocating memory,
and the failure indicates a memory allocation issue.
However, this function doesn't usually require a lot of memory.

I wondered if it was a 32-bit vs. 64-bit issue,
so I checked and confirmed that my program was compiled with Python 64-bit, and the affected user's PC (i7 12th gen, 16GB RAM) also runs a 64-bit OS, so that doesn't seem to be the problem either.

Considering it might be an issue with the version of the Visual C++ Runtime Library,
I advised the user to uninstall their current library, install the latest version, and then reboot, but the error persists.

I've been at this for days and just can't seem to figure out what I'm missing.
Any guidance or suggestions would be greatly appreciated. Thank you!

Hello, I am experiencing the same error. The same code works properly on two computers on Windows 10, but with one on Windows 11 I'm experiencing this issue.
Did you manage to fix it ?
it seems related to win32, to ctypes library in create_unicode_buffer and buftype() in particular

SOLVED for me:
I just identified the culprit ! It was SteelSeriesGG.exe app for the keyboard (bloatware **** ...), even in the tray it was somehow messing with it.
Basically you might have some app that messes with it and it can even be in the background, so try by closing them one by one. Hope it helps
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pywinauto typing in the wrong field EGameiro 0 745 Jun-07-2023, 10:01 PM
Last Post: EGameiro
  Help ~ coding with pywinauto NickNHartley 1 2,508 Apr-20-2023, 05:20 PM
Last Post: farshid
  pywinauto, anyone use it? thewolf 1 2,906 Mar-01-2021, 09:58 PM
Last Post: snippsat
  set_focus() in python pywinauto stearno 0 4,888 Nov-05-2020, 09:34 AM
Last Post: stearno
  Code starts slowing down? MemoryError AshkanDev 1 2,223 May-19-2020, 11:38 PM
Last Post: AshkanDev
  Kindly asking for help with Pywinauto louloulou 0 2,066 Mar-05-2020, 06:55 PM
Last Post: louloulou
  Getting MemoryError frames.write(buffer) kunwarsingh 0 1,656 Feb-10-2020, 09:39 PM
Last Post: kunwarsingh
  Checking the presence of label using pywinauto module Malt 0 1,983 Jul-26-2019, 09:06 AM
Last Post: Malt
  [PyWinAuto] Please help me with Typekeys () mattroi261192 2 8,018 Apr-23-2019, 01:55 AM
Last Post: mattroi261192
  Not able to convert PYWINAUTO module automation in exe file Utkarsh29 0 2,518 Mar-19-2019, 09:39 PM
Last Post: Utkarsh29

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020