URGENT ::::: Comment savoir si iexplorer est deja ouvert ???

theenjoy Messages postés 11 Date d'inscription vendredi 27 octobre 2000 Statut Membre Dernière intervention 26 août 2002 - 20 août 2002 à 00:24
TheSpyMan Messages postés 13 Date d'inscription mercredi 23 janvier 2002 Statut Membre Dernière intervention 2 mars 2003 - 20 août 2002 à 21:56
Comment faire pour savoir si iexplorer.exe est ouvert ou non ????

y a t il une fonction spéciale ????

merci de m aider

6 réponses

cs_raff Messages postés 182 Date d'inscription dimanche 18 août 2002 Statut Membre Dernière intervention 5 janvier 2004 3
20 août 2002 à 01:56
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

tu dois connaître la className de iexplorer et le nom de la fenêtre mais bon, si tu te débrouilles avec ça, tu peux avoir un return value qui te permette de savoir si explorer run ou non.
0
theenjoy Messages postés 11 Date d'inscription vendredi 27 octobre 2000 Statut Membre Dernière intervention 26 août 2002
20 août 2002 à 02:03
heu c quoi la classname ????

le reste ca va g capté mais c quoi ?
0
cs_raff Messages postés 182 Date d'inscription dimanche 18 août 2002 Statut Membre Dernière intervention 5 janvier 2004 3
20 août 2002 à 03:04
j'ai trouvé c'est "IEFrame". Le problème ici c'est que tu dois savoir le caption de la fenêtre. si fais
v = findWindow("IEFrame", "Caption") alors ça retourne le handle de la fenêtre (je crois). Tu ne peux pas mettre "*" ça ne marche pas. Il existe un moyen cependant de le faire seulement avec le class name, faudrait que tu regardes sur msdn...
raff
0
TheSpyMan Messages postés 13 Date d'inscription mercredi 23 janvier 2002 Statut Membre Dernière intervention 2 mars 2003
20 août 2002 à 17:32
Voila une methode pour savoir si une fenetre IE est ouverte

' Dans la form

Private Sub Timer1_Timer()
Dim IeOrnotIe
IeOrnotIe = GetText(findIEname)
If IeOrnotIe <> "" Then
' Code si fenetre ouverte
Else
' Code si fenetre non ouverte
End If

End Sub

Module :

Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Declare Function findwindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) 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

Public Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long

Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const wm_gettext = &HD
Public Const WM_GETTEXTLENGTH = &HE
Public Const WM_CLOSE = &H10

Public Function GetText(WindowHandle As Long) As String
Dim Buffer As String, TextLength As Long
TextLength& = sendmessage(WindowHandle&, WM_GETTEXTLENGTH, 0&, 0&)
Buffer$ = String(TextLength&, 0&)
Call SendMessageByString(WindowHandle&, wm_gettext, TextLength& + 1, Buffer$)
GetText$ = Buffer$
End Function

Public Function findIEname() As Long
' Renvoie le nom de la fenetre IE
ie& = findwindow(IEframe, vbNullString)
findIEname& = ie&
End Function

Voila, Bonne prog.
8-)
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
theenjoy Messages postés 11 Date d'inscription vendredi 27 octobre 2000 Statut Membre Dernière intervention 26 août 2002
20 août 2002 à 17:39
Oh putain c de la bombe ton code, juste un truc, quel code je peux mettre pour fermer iexplorer si il est ouvert ?
0
TheSpyMan Messages postés 13 Date d'inscription mercredi 23 janvier 2002 Statut Membre Dernière intervention 2 mars 2003
20 août 2002 à 21:56
Tu creer un boutton et tu mais code le suivant :
Private Sub cmdFermer_Click()
Dim winHwnd As Long
Dim RetVal As Long

If GetText(findIEname) = "" Then Exit Sub
winHwnd = findwindow(vbNullString, GetText(findIEname))

If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
If RetVal = 0 Then
MsgBox "Erreur"
End If
Else

End If

End Sub

Et ainsi il fermera la fenetre IE d'ouverte.

Bonne Continuation !
:big)
0
Rejoignez-nous