Hi all,
I'm trying to just read the text in one of the panels of a statusbar in a
different program. I have
tried the code below which works fine with notepad.
Can someone please help?
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Int32
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA"
(ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal
lpsz2 As String) As Int32
Private Declare Function GetMessageSTRING Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As
Int32, ByVal lParam As String) As Int32
Private Declare Function SendMessageSTRING Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As
Int32, ByVal lParam As String) As Int32
Private Const WM_SETTEXT = &HC
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Declare Auto Function SendMessage Lib "user32.dll" (ByVal hwnd
As Int32, ByVal _WM_USER As Integer, ByVal wParam As Integer, ByVal
windowText As StringBuilder) As Integer
Public Function GetText()
Try
Dim WindowStart As Integer
Dim ChildWindowTxt As Integer
Dim getstring As String
WindowStart = FindWindow("NewProg", vbNullString)
ChildWindowTxt = FindWindowEx(WindowStart, 0&, "statusbar5",
vbNullString)
Dim textSize As Integer = 1024
Dim buffer As New StringBuilder(textSize)
SendMessage(ChildWindowTxt, WM_GETTEXT, textSize, buffer)
MessageBox.Show(buffer.ToString())
Catch ex As Exception
End Try
End Function
thanks
gv