Excel Activer un bouton d'internet Explorer avec sont Handle

jojo869 Messages postés 6 Date d'inscription mercredi 16 janvier 2008 Statut Membre Dernière intervention 25 novembre 2009 - 23 nov. 2009 à 14:04
jojo869 Messages postés 6 Date d'inscription mercredi 16 janvier 2008 Statut Membre Dernière intervention 25 novembre 2009 - 25 nov. 2009 à 07:53
Bonjour à tous,

j'aimerais cliquer automatiquement sur le bouton Ouvrir de la boite de telechargement d'internet explorer.

Voici ce que j'ai déjà essayé de faire :

Option Explicit 

Private Declare Function BringWindowToTop Lib "user32" _ 
    (ByVal hwnd As Long) As Long 

Private Declare Function FindWindow Lib "user32" Alias _ 
    "FindWindowA" (ByVal lpClassName As String, _ 
    ByVal lpWindowName As String) As Long 

Private Declare Function ShowWindow Lib "user32" _ 
    (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long 

Private Declare Function Putfocus Lib "user32" Alias "SetFocus" _ 
    (ByValhwnd As Long) As Long 
    
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ 
(ByValhwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long 

Private 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 

Private Declare Function SetActiveWindow Lib "user32.dll" (ByVal hwnd As Long) As Long 
Private Const BM_CLICK = &HF5 
Sub ApplicationPremierPlan() 
    Dim hwnd, hwnd_button As Long 
    hwnd = FindWindow(vbNullString, "Téléchargement de fichier") 
    If hwnd > 0 Then 
        SetActiveWindow (hwnd) 
        Do 
        hwnd_button = FindWindowEx(hwnd, 0, "Button", "&Ouvrir") 
        Loop While hwnd_button = 0 
        SetActiveWindow (hwnd) 
        SendMessage hwnd_button, BM_CLICK, ByVal CLng(0), ByVal CLng(0) 
    End If 
End Sub 



Il y a certainement beaucoup de choses à revoir mais je ne comrpend pas comment déterminer le nom de mon bouton à actionner existe-t-il un utilitaire? (Je parle de cette ligne hwnd_button = FindWindowEx(hwnd, 0, "Bouton", "&Ouvrir") et plus precisement : &Ouvrir)

Merci à vous !

2 réponses

jojo869 Messages postés 6 Date d'inscription mercredi 16 janvier 2008 Statut Membre Dernière intervention 25 novembre 2009
23 nov. 2009 à 15:00
Bon j'ai du nouveau, j'arrive à recuperer le handle de ma fenetre et de mon bouton mais je n'arrive pas à le clicker...

Voici mon code :
Option Explicit

Private Declare Function FindWindow Lib "user32" Alias _
    "FindWindowA" (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByValhwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long

Private 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

Private Declare Function SetActiveWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
Private Const BM_CLICK = &HF5

Sub ApplicationPremierPlan()
Dim hwnd, hwnd_button As Long
hwnd = FindWindow(vbNullString, "Téléchargement de fichier")
If hwnd > 0 Then
    hwnd_button = FindWindowEx(hwnd, 0, "Button", "Ou&vrir")
    MsgBox hwnd_button
    SetActiveWindow (hwnd)
    SendMessage hwnd_button, BM_CLICK, 0, 0
End If
End Sub
0
jojo869 Messages postés 6 Date d'inscription mercredi 16 janvier 2008 Statut Membre Dernière intervention 25 novembre 2009
25 nov. 2009 à 07:53
Pas de réponse ???

J'ai abandonné l'idée du senmessage, et j'aimerais utiliser SendKeys mais ça ne fonctionne pas du tout j'en ai marre...
0
Rejoignez-nous