winapi

Having trouble using winapi to read input from a device

Having trouble using winapi to read input from a device Question: I followed the steps here to try and read some input from a device. I’ve been trying for a couple hours now to figure out why GetMessage doesn’t return anything. Originally I was trying to read from a certain device, but seeing as that …

Total answers: 2

Tkinter – Floating Window – Resize

Tkinter – Floating Window – Resize Question: Inspired by this question, I would like to write my own resizing function for my root window. But I just noticed that my code shows some performance issues. If you resize it quickly you can see that the window doesn’t finds its height prompt as I wish, it …

Total answers: 3

Detect if key was pressed once

Detect if key was pressed once Question: I wanted to do an action, as soon as my f key is pressed. The problem is that it spams the action. import win32api while True: f_keystate = win32api.GetAsyncKeyState(0x46) if f_keystate < 0: print(“Pressed!”) I would like this without “Pressed!” being spammed but only printed once. Asked By: …

Total answers: 3

Is it possible to check chromedriver.exe version at runtime in python?

Is it possible to check chromedriver.exe version at runtime in python? Question: I’m trying to check compatibility of chrome and chromedriver to prompt the user to download the correct chromedriver version if needed. I’m looking to check the version of chrome driver in a way similar to how i check chrome.exe shown below. from win32api …

Total answers: 3

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

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

Force wifi scan using WlanScan in Python

Force wifi scan using WlanScan in Python Question: I want to know how to execute the WlanScan function from python to initiate a wireless network scan. I am using python module win32wifi. It requires a handle obtained using WlanOpenHandle and an interface GUID pInterfaceGuid. I have no idea how to get this GUID. any help …

Total answers: 2

Python Windows Enum Installed Fonts

Python Windows Enum Installed Fonts Question: I am trying to get a list of installed fonts on Windows machines so that I can then install missing ones. I’m on Py3.*, Windows 7. Looking through the win API documentation I know that I need to use EnumFontFamiliesExW however I’m not sure what the correct syntax is …

Total answers: 1

How to optimize conversion from PyCBitmap to OpenCV image

How to optimize conversion from PyCBitmap to OpenCV image Question: I’ve got this bit of code, and it works… But it runs very slow: hwin = win32gui.GetDesktopWindow() width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCREEN) height = win32api.GetSystemMetrics(win32con.SM_CYVIRTUALSCREEN) left = win32api.GetSystemMetrics(win32con.SM_XVIRTUALSCREEN) top = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN) hwindc = win32gui.GetWindowDC(hwin) srcdc = win32ui.CreateDCFromHandle(hwindc) memdc = srcdc.CreateCompatibleDC() bmp = win32ui.CreateBitmap() bmp.CreateCompatibleBitmap(srcdc, width, height) memdc.SelectObject(bmp) …

Total answers: 2

How to detect that stdio was redirected to nul?

How to detect that stdio was redirected to nul? Question: I’m developing a package to fix several issues with Unicode in Python run in standard Windows console environment: https://github.com/Drekin/win-unicode-console. The key operation is to replace the standard stream objects when needed. For this I need to detect whether the standard streams were redirected or not. …

Total answers: 1