开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜