There are some declarations and code that you can erase to make it shorter.
Code: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 GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Sub Form_Load() Dim hResult hResult = FindWindowEx(FindWindowEx(0, 0, "SciCalc", vbNullString), 0&, "Static", vbNullString) Debug.Print GetWndText(hResult) End Sub Private Function GetWndText(ByVal hwnd As Long) Dim temp As String * 255 GetWindowText hwnd, temp, 255 GetWndText = Left(temp, Len(temp) - InStr(1, temp, vbNullChar)) End Function




Reply With Quote