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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) 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, _
ByVal lParam As String _
) As Long
Private Declare Function ShowWindow _
Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nCmdShow As Long _
) As Long
Private Const BM_CLICK As Long = &HF5
Private Const ClassName1 As String = "JULIE"
Private Const ClassName2 As String = "#32770"
Private Const ClassName3 As String = "BOUTON"
Private Const WindowName1 As String = "JULIE:W"
Private Const WindowName2 As String = "ACQ"
Private Const WindowName3 As String = "BB:Import^Importer une radio, une image"
Private Const WindowName4 As String = "Ouvrir"
Private Handle1 As Long = 0
Private Handle2 As Long = 0
Private Handle3 As Long = 0
Private Sub Findwin()
' trouver le hwdn de la fenetre principale de JULIE
Handle1 = FindWindow(ClassName1, WindowName1)
' trouver le hwdn de la fenetre fille ACQ
Handle2 = FindWindow(ClassName2, WindowName2)
' trouver le hwdn du bouton parcourir
Handle3 = FindWindowEx(Handle1, Handle2, "ClassName3", WindowName3)
End Sub
Private Sub SendMSG()
SendMessage(Handle3, BM_CLICK, 0, 0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Findwin()
lbl_HW1.Text = Handle1
lbl_HW2.Text = Handle2
lbl_HW3.Text = Handle3
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SendMSG()
End Sub |