我使用EnumDesktopWindows()获取正在运行的应用程序的窗口句柄,然后使用GetWindowText()获取每个窗口的标题。
用户选择一个窗口然后我使用FindWindow()来定位并激活它。这一切都运行良好,已经做了好几年,直到我转移到Windows 10.它仍适用于除Microsoft Edge之外的所有内容。传递边缘浏览器的窗口文本时,API返回零值(IntPtr.Zero)。
我在VB.NET工作,但这真的是关于Win32 API和Edge。我已经包含了我在下面调用的API函数的定义:
Private Declare Auto Function EnumDesktopWindows Lib "user32" (ByVal hDesktop As Integer, ByVal lpfn As EnumDesktopWindowsDelegate, ByVal param As Integer) As Integer
Private Delegate Function EnumDesktopWindowsDelegate(hWnd As IntPtr, lParam As Integer) As Boolean
Private Shared Function GetWindowText(ByVal hwnd As IntPtr, ByVal lpString As Text.StringBuilder, ByVal cch As Integer) As Integer
Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr