Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将一些文本放入正在运行的应用程序中,当使用全局热键调用我的程序在后台运行时,我想获取焦点应用程序的进程 ID。
我的操作系统是 Ubuntu,我正在使用带有 C++ 的 QT。但我也打算对 Windows 做同样的事情。所以任何帮助表示赞赏。
在 windows 下,您可以尝试使用 GetForegroundWindow 来获取用户当前正在使用的窗口的 HWND。如果可行,则可以使用 GetWindowThreadProcessId 获取该应用程序的进程 ID。