1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow _
Lib "user32" (ByVal hWnd 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 SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_SETTEXT = &HC
Public Const BM_CLICK As Long = &HF5&
Public Sub Upload_Set_Filename(sFilePathName As String)
Dim hWnd As Long
Dim timeout As Date
timeout = Now + TimeValue("00:00:10")
Do
hWnd = FindWindow("#32770", "Choisir un fichier à télécharger")
DoEvents
Loop Until hWnd Or Now > timeout
If hWnd Then
SetForegroundWindow (hWnd)
hWnd = FindWindowEx(hWnd, 0, "ComboBoxEx32", vbNullString)
End If
If hWnd Then
hWnd = FindWindowEx(hWnd, 0, "ComboBox", "")
End If
If hWnd Then
SetForegroundWindow (hWnd)
hWnd = FindWindowEx(hWnd, 0, "Edit", "")
End If
If hWnd Then
SendMessage hWnd, WM_SETTEXT, 0, ByVal sFilePathName
End If
End Sub |
Partager