Class name, HWNDs from PID
how do I get class name and HWNDs of a proce开发者_如何学Pythonss where only PID is known?
I need to set focus on a particular window of a process.
There is no way to go directly from PID >> HWND since a PID can own multiple windows. You can however go the other way round.
- Enumerate all top-level windows (EnumWindows)
- In the callback, get each window's associated PID (GetWindowThreadProcessId) and class name (GetClassName)
- If it's a match, set the focus (SetForegroundWindow)
精彩评论