This should get the text of the calculators result window:
Code:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Sub Form_Load() Dim hcalcwnd As Long, hResultwnd As Long hcalcwnd = FindWindow("SciCalc", vbNullString) hResultwnd = FindWindowEx(hcalcwnd, 0&, "Static", vbNullString) Debug.Print GetWndText(hResultwnd) End Sub Private Function GetWndText(hwnd As Long) Dim l As Long, temp As String l = GetWindowTextLength(hwnd) temp = Space(l) GetWindowText hwnd, temp, l l = InStr(temp, vbNullChar) - 1 If l Then GetWndText = Left(temp, l) Else GetWndText = temp End If End Function





Reply With Quote