Activer un bouton d'internet Explorer avec sont Handle
Bonjour,
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, "Bouton", "&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 !
bonjour
j'aime assez les macroteurs Windows AutoIt ou AutoHotkey (gratuits)
à essayer
Ok je vais tester ça !
Bon, déjà j'ai réussi à trouver le nom exact de mon bouton.
" Ou&vrir " ce qui était logique car le v était souligné.
j'arrive donc à obtenir le handle du bouton mais je n'arrive pas à clicker dessus.
Pourquoi mon bouton n'est pas clicker voici mon code (complet) :
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")
SetActiveWindow (hwnd)
SendMessage hwnd_button, BM_CLICK, 0, 0
End If
End Sub
Merci beaucoup de votre soutien.
Helas, je ne trouve pas de "dossier" la dessus sur le net...
Rien de bien concluant...
Salut le forum
Quel version d'Internet Explorer et ouvrir depuis quelle adresse...
Mytå
Il s'agit du vieux internet explorer celui sous windows 2000...
Et pour l'adresse tu pourrais être plus precis? (je ne vois pas ce que c'est)
Ah pour l'adresse je pense que tu parlais de l'adresse du fichier.
Pour le moment j'ai mis un fichier Word en local sur un serveur apache.
L'adresse est donc :
http://127.0.0.1/MonDocument.Doc
Bon, voici ou j'en suis ce matin :
J'arrive à appuyer des boutons de la calculatrice windows via excel.
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
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 SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hWnd As Long) As Long
Const WM_COMMAND As Integer = &H111
Sub Test()
Dim ParentWndHandle As Long
'Obtenir le handle de la fenetre
ParentWndHandle = FindWindow("SciCalc", "Calculatrice")
If ParentWndHandle <> 0 Then
Dim ChildWndHandle As Long
ChildWndHandle = FindWindowEx(ParentWndHandle, 0, "Button", "7")
Call SendMessage(ParentWndHandle, WM_COMMAND, &H83, ChildWndHandle)
End If
End Sub
J'ai fait la même manipulation pour Internet explorer, j'ai extrait vian spy++ la Class du bouton ainsi que son numero d'identification en Hexa.
Voici ce que me donne le code (les declarations restent les même) :
Const WM_COMMAND As Integer = &H111
Sub Test()
Dim ParentWndHandle As Long
'Obtenir le handle de la fenetre
ParentWndHandle = FindWindow("#32770", "Téléchargement de fichier")
If ParentWndHandle <> 0 Then
Dim ChildWndHandle As Long
'Obtenir le handle du bouton
ChildWndHandle = FindWindowEx(ParentWndHandle, 0, "Button", "Ou&vrir")
Call SendMessage(ParentWndHandle, WM_COMMAND, &H1147, ChildWndHandle)
End If
End Sub
Je pense que ce code est à peut près logique.
J'ai essayé d'inserer un PutFocus avant le SendMessage, mais rien à faire.
Merci à ceux qui voudrons bien m'aider.