pywin32

PyInstaller won't import pywin32 / win32clipboard – ImportError upon running executable

PyInstaller won't import pywin32 / win32clipboard – ImportError upon running executable Question: I’m working in Windows 10 with Python 3.8.6 and using PyInstaller 4.0 to compile my script as an executable for distribution. I just added a feature today that required importing win32clipboard. PyInstaller finishes compiling without any errors, but the excecutable fails to load …

Total answers: 2

How to get the authenticated user name in Python when fronting it with IIS HTTP PlatformHandler and using Windows auth?

How to get the authenticated user name in Python when fronting it with IIS HTTP PlatformHandler and using Windows auth? Question: HttpPlatformHandler supports forwarding the auth token by enabling the forwardWindowsAuthToken setting in the web.config. This sounds like a useful feature when needing to use Windows Integrated Authentication. The document on this is very vague …

Total answers: 1

How to exit cleanly from Flask and 'waitress' running as a Windows pywin32 service

How to exit cleanly from Flask and 'waitress' running as a Windows pywin32 service Question: I have managed to cobble together a working demo of a pywin32 Windows service running Flask inside the Pylons waitress WSGI server (below). A niece self contained solution is the idea… I have spent hours reviewing and testing ways of …

Total answers: 1

Passing utf-16 string to a Windows function

Passing utf-16 string to a Windows function Question: I have a Windows dll called some.dll with the following function: void some_func(TCHAR* input_string) { … } some_func expects a pointer to utf-16 encoded string. Running this python code: from ctypes import * some_string = “disco duck” param_to_some_func = c_wchar_p(some_string.encode(‘utf-16’)) # here exception! some_dll = ctypes.WinDLL(some.dll) some_dll.some_func(param_to_some_func) …

Total answers: 1

PyWin32 (226) and virtual environments

PyWin32 (226) and virtual environments Question: [PyPI]: pywin32 226 has been released on 20191110. It works on most of the Python installations (e.g. works on the official versions downloaded from Python), but not on virtual environments (e.g. created with VirtualEnv (v16.7.7), and (based on further research) Python‘s venv). I used Python v3.8.0 and v3.7.3 as …

Total answers: 1

PyWin32 and Python 3.8.0

PyWin32 and Python 3.8.0 Question: Python 3.8.0 has been recently released (on 20191014, and can be downloaded from [Python]: Python 3.8.0). PyWin32 has builds for it on [PyPI]: pywin32 225 (released on 20190915). Unfortunately, after pip installing, it doesn’t work. Sample: [cfati@CFATI-5510-0:e:WorkDevStackOverflowq058631512]> sopr.bat *** Set shorter prompt to better fit when pasted in StackOverflow (or …

Total answers: 2

How to fix "ImportError: DLL load failed" while importing win32api

How to fix "ImportError: DLL load failed" while importing win32api Question: I’m setting up an autoclicker in Python 3.8 and I need win32api for GetAsyncKeyState but it always gives me this error: >>> import win32api Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: DLL load failed while importing win32api: The specified …

Total answers: 31

Get user date format in Windows

Get user date format in Windows Question: My question is similar to this one, however, I don’t want to get the date format of the locale, but the one set by the user. The reason is that I am using the pywin32 api to communicate with Outlook, specifically to filter mails by date. The format …

Total answers: 1

Unable to get all available networks using WlanGetAvailableNetworkList in Python

Unable to get all available networks using WlanGetAvailableNetworkList in Python Question: I am trying to get the list of all available networks using WlanGetAvailableNetworkList. The scan returns an object which contains NumberOfItems. When I loop over the array of networks based NumberOfItems it only shows me the first network and anything beyond that gives me …

Total answers: 1

How to mute/unmute sound using pywin32?

How to mute/unmute sound using pywin32? Question: My searches lead me to the Pywin32 which should be able to mute/unmute the sound and detect its state (on Windows 10, using Python 3+). I found a way using an AutoHotkey script, but I’m looking for a pythonic way. More specifically, I’m not interested in playing with …

Total answers: 2