Hi all!
I want to receive the time and if the mediaplayer is paused using api.
My problem is that the child is called Static but there’s 3 items there and it seems that I just get the first of them.
Any one please?
Heres my code so far:
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
Private Declare Function SendMessageString Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As IntPtr
Private Const WM_GETTEXT As Integer = &HD
Dim parent As IntPtr
Dim child1 As IntPtr
Dim child2 As IntPtr
Dim s As String = Nothing
parent = FindWindow("MediaPlayerClassicW", Nothing) 'get window handle
child1 = FindWindowEx(parent, IntPtr.Zero, "#32770", Nothing)
child2 = FindWindowEx(child1, IntPtr.Zero, "Static", Nothing)
SendMessageString(child2, WM_GETTEXT, 50, s)
MsgBox(s)
That indicates that the search should start from the parent. Once you have the first child of that type, you call FindWindowEx again and specify the first child as the starting point for the search. That will give you the second child of that type. You can keep on calling FindWindowEx with the previous child handle to go through every child of a particular type.
Thanks for taken the time
I think I understand but I cant get it to work. Maybe I use SendMessageString wrong?
However I do get a handle:
Code:
Dim parent As IntPtr
Dim child1 As IntPtr
Dim child2 As IntPtr
Dim child3 As IntPtr
Dim s As String = Nothing
parent = FindWindow("MediaPlayerClassicW", Nothing) 'get window handle
child1 = FindWindowEx(parent, IntPtr.Zero, "#32770", Nothing)
child2 = FindWindowEx(child1, IntPtr.Zero, "Static", Nothing)
child3 = FindWindowEx(child1, child2, "Static", Nothing)
SendMessageString(child3, WM_GETTEXT, 50, s)
MsgBox(s)
Here the "s" returns nothing.
But if I do like this: