| Declare Function GetForegroundWindow Lib "user32.dll" () As Long Const GW_HWNDNEXT = 2 Const WM_GETTEXT = &HD Const WM_GETTEXTLENGTH = &HE Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal lpszClass As Any, ByVal lpszWindow As Any) As Long Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal Hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Declare Function GetWindowThreadProcessId Lib "user32" (ByVal Hwnd As Long, lpdwprocessid As Long) As Long Function GetCaption(Hwnd As Long) As String Dim Wintext As String Dim slength As Long Dim retval As Long 'Gets the Length of the Caption slength = SendMessage(Hwnd, WM_GETTEXTLENGTH, ByVal CLng(0), ByVal CLng(0)) + 1 'Makes Space for the Caption Wintext = Space(slength) 'Gets The Caption retval = SendMessage(Hwnd, WM_GETTEXT, ByVal slength, ByVal Wintext) 'Puts It in GetCaption GetCaption = Left(Wintext, retval) End Function Function GetTopWindowCaption() As String GetTopWindowCaption = GetCaption(GetForegroundWindow) End Function |
Get Top Window Caption |
India web developer web development India | Freelance web development ecommerce web developer | Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design