MD9547
07-04-2005, 10:23 AM
The following is supposed to check if Internet Explorer Is Running, but my get_win_title function always seems to return an empty string, except when the active window is my app, then my apps title is retrieved correctly by the function. Anyone know what I'm doing wrong? :confused:
Private Declare Function GetActiveWindow 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 Function get_win_title() As String
Dim buf As String * 1024
Dim length As Long
Dim ahWnd As Long
ahWnd = GetActiveWindow()
length = GetWindowText(ahWnd, buf, Len(buf))
get_win_title = Left$(buf, length)
End Function
Private Sub Form_Load()
Me.Visible = False
Timer1.Interval = 5000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If Right(get_win_title, 29) = "- Microsoft Internet Explorer" Then
MsgBox "Uh oh!"
End If
End Sub
Private Declare Function GetActiveWindow 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 Function get_win_title() As String
Dim buf As String * 1024
Dim length As Long
Dim ahWnd As Long
ahWnd = GetActiveWindow()
length = GetWindowText(ahWnd, buf, Len(buf))
get_win_title = Left$(buf, length)
End Function
Private Sub Form_Load()
Me.Visible = False
Timer1.Interval = 5000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If Right(get_win_title, 29) = "- Microsoft Internet Explorer" Then
MsgBox "Uh oh!"
End If
End Sub