Reputation: 10542
Hey all i am trying to figure out how to get all the way down where it says:
Window 00211286 "" QWidget
Highlighted in green is what i am trying to find with the code below:
Currently i have this:
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
I get a value for FindWindow and then also for the first findwindowEx.... but after that i get a big fat 0. Then for the last FindWindowEx i get the same number as i did on the first findwindowEx.
Any help would be great!
Upvotes: 1
Views: 3930
Reputation: 39122
Try this out:
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
Note what happens in these two lines:
Dim hwndButton As Long = FindWindowEx(hwndParent, IntPtr.Zero, "QWidget", "") ' First Child QWidget
hwndButton = FindWindowEx(hwndParent, hwndButton, "QWidget", "") ' Second Child QWidget
The first line gets the first QWidget that has a handle of 001816EC. In the second line we use the same parent handle, but we pass in the handle of the previously found widget to the second parameter called "hWndChildAfter". This gets the second QWidget that has a handle of 0011686A. These two windows are "siblings" to each other.
Upvotes: 1