开发者

Class name, HWNDs from PID

开发者 https://www.devze.com 2023-03-17 13:51 出处:网络
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 sinc

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

精彩评论

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