Skip to content Skip to sidebar Skip to footer

Why Windll.user32.GetWindowThreadProcessID Can't Find The Function?

I'm reading Black Hat Python and in chapter 8 I find 'user32.GetWindowThreadProcessID(hwnd,byref(pid))' doesn't work, just like the picture shows. It seems that python can't find G

Solution 1:

It should work if you your OS version is at least Windows 2000 Professional:

import ctypes
import ctypes.wintypes
pid = ctypes.wintypes.DWORD()
hwnd = ctypes.windll.user32.GetForegroundWindow()
print( ctypes.windll.user32.GetWindowThreadProcessId(hwnd,ctypes.byref(pid)) )

Post a Comment for "Why Windll.user32.GetWindowThreadProcessID Can't Find The Function?"