1

ねえ、私はそれが言うところまでずっと降りる方法を理解しようとしています:

ウィンドウ 00211286 "" QWidget

ここに画像の説明を入力

緑色で強調表示されているのは、以下のコードで見つけようとしているものです。

ここに画像の説明を入力 現在、私はこれを持っています:

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWndParent As IntPtr, ByVal hWndChildAfter As Integer, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
Public Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)

Public Const WM_CHAR = &H102
Private Const BM_CLICK = &HF5
Public Const WM_LBUTTONDBLCLK = &H203
Public Const ENTER_KEY = 13

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim hwndParent As Long = FindWindow(vbNullString, "Genymotion")
    Dim hwndButton As Long = FindWindowEx(hwndParent, IntPtr.Zero, "QWidget", "")
    hwndButton = FindWindowEx(hwndButton, IntPtr.Zero, "QWidget", "content")
    hwndButton = FindWindowEx(hwndButton, IntPtr.Zero, "QWidget", "mainFrame")
    hwndButton = FindWindowEx(hwndButton, IntPtr.Zero, "QWidget", "")
    hwndButton = FindWindowEx(hwndButton, IntPtr.Zero, "QWidget", "qt_scrollarea_viewport")
    hwndButton = FindWindowEx(hwndButton, IntPtr.Zero, "QWidget", "")
End Sub

FindWindow の値を取得し、次に最初の findwindowEx の値も取得します....しかし、その後、大きな脂肪 0 を取得します。次に、最後の FindWindowEx について、最初の findwindowEx で行ったのと同じ番号を取得します。

どんな助けでも素晴らしいでしょう!

4

1 に答える 1

1

これを試してください:

    Dim hwndParent As Long = FindWindow(vbNullString, "Genymotion") ' Parent Window by Caption
    Dim hwndButton As Long = FindWindowEx(hwndParent, IntPtr.Zero, "QWidget", "") ' First Child QWidget
    hwndButton = FindWindowEx(hwndParent, hwndButton, "QWidget", "") ' Second Child QWidget
    hwndButton = FindWindowEx(hwndButton, IntPtr.Zero, "QWidget", "content") ' "content" QWidget
    hwndButton = FindWindowEx(hwndButton, IntPtr.Zero, "QWidget", "mainFrame") ' "mainFrame" QWidget
    hwndButton = FindWindowEx(hwndButton, IntPtr.Zero, "QWidget", "") ' First Child QWidget
    hwndButton = FindWindowEx(hwndButton, IntPtr.Zero, "QWidget", "qt_scrollarea_viewport") ' "qt_scrollarea_viewport" QWidget
    hwndButton = FindWindowEx(hwndButton, IntPtr.Zero, "QWidget", "") ' First Child QWidget

次の 2 行で何が起こるかに注意してください。

    Dim hwndButton As Long = FindWindowEx(hwndParent, IntPtr.Zero, "QWidget", "") ' First Child QWidget
    hwndButton = FindWindowEx(hwndParent, hwndButton, "QWidget", "") ' Second Child QWidget

最初の行は、001816EC のハンドルを持つ最初の QWidget を取得します。2 行目では、同じ親ハンドルを使用しますが、以前に見つかったウィジェットのハンドルを「hWndChildAfter」という 2 番目のパラメーターに渡します。これにより、0011686A のハンドルを持つ 2 番目の QWidget が取得されます。これら 2 つのウィンドウは、互いに "兄弟" です。

于 2013-11-08T17:42:57.283 に答える