How to get the window title of external application
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 'System & API - How to get the window title of external application Option Explicit 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 Public Function GetWindowTitle(ByVal hwnd As Long) As String Dim l As Long Dim s As String l = GetWindowTextLength(hwnd) s = Space$(l + 1) GetWindowText hwnd, s, l + 1 GetWindowTitle = Left$(s, l) End Function |