'fenetres_IE ("http://boursorams.com") envoie Boursorama sur toutes les fenetres ie 'fenetres_IE énumère les fenetres ie ouvertes Declare Function cherche_fenetre Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long Declare Function get_titre Lib "user32" Alias "GetWindowTextA" _ (ByVal hwnd As Long, ByVal lpString As String, _ ByVal cch As Long) As Long Declare Function GetWindow Lib "user32" _ (ByVal hwnd As Long, ByVal wCmd As Long) As Long Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _ (ByVal hwnd As Long, ByVal lpClassName As String, _ ByVal nMaxCount As Long) As Long Declare Function SendMessage_ Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) As Long Declare Function apiGetKeyboardState Lib "user32" _ Alias "GetKeyboardState" (pbKeyState As Byte) As Long Dim clavier(0 To 255) As Byte Sub liste_des_fenetres_IE() fenetres_IE End Sub Sub fermer_toutes_les_fenetres_IE() 'on redirige chaque fenetre vers un javascript de fermeture fenetres_IE ("javascript:window.close()") End Sub Sub fenetres_IE(Optional adr = "") niv1 = cherche_fenetre(0, 0) 'recherche de IEFrame******************************************* Do While niv1 <> 0 If classe(niv1) = "CabinetWClass" Or classe(niv1) = "IEFrame" Then 'recherche de Worker******************************************* niv2 = GetWindow(niv1, 5) Do While niv2 <> 0 If classe(niv2) = "WorkerA" Or classe(niv2) = "WorkerW" Then 'recherche de ReBar******************************************* niv3 = GetWindow(niv2, 5) Do While niv3 <> 0 If classe(niv3) = "ReBarWindow32" Then 'recherche de ComboBoxEx32******************************************* niv4 = GetWindow(niv3, 5) Do While niv4 <> 0 If classe(niv4) = "ComboBoxEx32" Then 'recherche de ComboBox******************************************* niv5 = GetWindow(niv4, 5) Do While niv5 <> 0 If classe(niv5) = "ComboBox" Then 'recherche de Edit******************************************* niv6 = GetWindow(niv5, 5) Do While niv6 <> 0 If classe(niv6) = "Edit" Then If adr = "" Then 'donne l'adresse indiquée dans la boite d'entrée 'et le titre de la page MsgBox "URL (dans la barre d'adresse) :" & Chr(10) & adrURL(niv6) & _ Chr(10) & Chr(10) & "titre du document :" & Chr(10) & titre(niv1) Else 'pour MODIFIER l'URL des fenetres IE apiGetKeyboardState clavier(0) 'état du clavier SendMessage_ niv6, &HC, 0, ByVal CStr(adr & vbNullChar) 'envoie l'URL SendMessage_ niv6, &H100, &HD, clavier(&HD) 'envoie "enter" End If End If 'fenetre Edit niv6 = GetWindow(niv6, 2) Loop '******************************************* End If 'fenetre ComboBox niv5 = GetWindow(niv5, 2) Loop '******************************************* End If 'fenetre ComboBoxEx32 niv4 = GetWindow(niv4, 2) Loop '******************************************* End If 'fenetre rebar niv3 = GetWindow(niv3, 2) Loop '******************************************* End If 'fenetre worker niv2 = GetWindow(niv2, 2) Loop '******************************************* End If 'fenetre ie niv1 = GetWindow(niv1, 2) Loop End Sub Function classe(pointeur) As String classe = String(100, Chr$(0)) GetClassName pointeur, classe, 100 classe = Left$(classe, InStr(classe, Chr$(0)) - 1) End Function Function titre(pointeur) As String titre = String(100, Chr$(0)) get_titre pointeur, titre, 100 titre = Left$(titre, InStr(titre, Chr$(0)) - 1) End Function Function adrURL(pointeur) As String nbcar = SendMessage_(pointeur, &HE, 0, ByVal 0&) adrURL = String(nbcar + 1, Chr$(0)) nbcar = SendMessage_(pointeur, &HD, nbcar + 1, ByVal adrURL) adrURL = Left$(adrURL, nbcar) End Function