03. marts 2002 - 12:38
Der er
4 kommentarer og
1 løsning
IE...test
Halløj derude...
Jo for at gå direkte til sagen:
Jeg vil gerne kunne vide, om IE er åbnet. Det er det hele.
Det er ret vigtigt at der ikke er nogen alvorlige "overheads".
Kodestumper ville værep rart
på forhånd tak
//NHJ
03. marts 2002 - 12:49
#1
'-------------------------------- Form1 --------------------------------
Private Sub Form_Load()
If ActivateAppHwnd("*Microsoft Internet Explorer", False) Then
Me.Caption = "IE er open"
Else
Me.Caption = "IE er ikke open"
End If
End Sub
'-------------------------------- Form1 --------------------------------
'-------------------------------- Module1 --------------------------------
Option Explicit
Public Declare Function EnumChildWindows Lib "user32" (ByVal hwndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Any) As Long
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function EnumWindows& Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam 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 IsWindowVisible& Lib "user32" (ByVal hwnd As Long)
Private Declare Function GetParent& Lib "user32" (ByVal hwnd As Long)
Public Const WM_GETTEXTLENGTH = &HE
Public Const WM_GETTEXT = &HD
Dim sPattern As String, hFind As Long
Public VCount As Integer, ICount As Integer
Private Function FindActivateTitle(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim k As Long, sName As String
If IsWindowVisible(hwnd) And GetParent(hwnd) = 0 Then
sName = Space$(128)
k = GetWindowText(hwnd, sName, 128)
If k > 0 Then
sName = Left$(sName, k)
If lParam = 0 Then sName = UCase(sName)
If sName Like sPattern Then
hFind = hwnd
FindActivateTitle = 0
Exit Function
End If
End If
End If
FindActivateTitle = 1
End Function
Function ActivateAppHwnd(sTitle As String, Optional sMatchCase As Boolean = True) As Long
sPattern = sTitle: hFind = 0
If Not sMatchCase Then sPattern = UCase(sPattern)
EnumWindows AddressOf FindActivateTitle, sMatchCase
ActivateAppHwnd = hFind
End Function
'-------------------------------- Module1 --------------------------------
03. marts 2002 - 15:30
#3
I IE vinduet står der altid "Microsoft Internet Explorer" til sidst, den søger efter vinduet "*Microsoft Internet Explorer" * betyder at bare der står "Microsoft Internet Explorer" sidst i titlen af vinduet så er den ok.
'Den lopper ikke, så må du lave det med en timer.
Private Sub Form_Load()
Timer1.Interval = 1000 '1. sek
End Sub
Private Sub Timer1_Timer()
If ActivateAppHwnd("*Microsoft Internet Explorer", False) Then
Me.Caption = "IE er open"
Else
Me.Caption = "IE er ikke open"
End If
End Sub