[英]In Windows how to get highlighted text in a window that belongs to another process using C++ or C#?
[英]C#, C++ , WinAPI - Get Number of windows from another process
它可以在 C# 或 C++ 或 WinAPI 中回答(我知道如何 pInvoke)。
我想要達到的目標。 我想獲取由另一個應用程序打開的 windows 的數量。 例如我有聊天應用程序。 我想獲取 windows 的號碼,因為我不想檢測是否有人向我發送消息(新傳入消息 = 多一個窗口)。
所以簡而言之。 如何獲取另一個進程打開的 windows 的編號。
如果您有其他應用程序的進程 ID,這里有一個可能的 Windows API 方式:
Enumerate all top level windows with the EnumWindows function, using GetWindowThreadProcessId in the callback function to test for main windows belonging to your given process. 從匹配主 windows 然后您可以繼續枚舉其所有子 windows 與EnumChildWindows 。
首先,您需要頂級 window 的句柄。 如果您知道 window 的名稱,則FindWindow()會檢索它。
第二步已經在 SO 上解釋過很多次了:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.