Rather than detect all programs, I would recommend just checking the one that is currently being used.
To do that you can use the GetForeGroundWindow API (which returns the hWnd of the window that has focus):
...and GetWindowText should give you the title:Code:Private Declare Function GetForegroundWindow Lib "user32" () As Long
This is untested, but might work:Code:Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Code:Dim lnghWnd as Long Dim strText As String lnghWnd = GetForeGroundWindow strText = String(500, Chr$(0)) GetWindowText lnghWnd, strText, 500 MsgBox strText




Reply With Quote