This should return the titlebar caption of the foreground window , if that helps?
Code:
Option Explicit
Private Declare Function GetForegroundWindow Lib "user32" () 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 Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal Hwnd As Long) As Long
Public Function GetActiveTitle() As String
' // Return title bar caption of foreground program.//
Dim Length As Long, CurrWnd As Long
Dim sItem As String
CurrWnd = GetForegroundWindow
Length = GetWindowTextLength(CurrWnd)
sItem = Space$(Length + 1)
Length = GetWindowText(CurrWnd, sItem, Length + 1)
GetActiveTitle = Mid(sItem, 1, Len(sItem) - 1)
End Function
Code:
Private Sub Timer1_Timer()
Text1 = GetActiveTitle
End Sub