Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, Byval LPSZ2 AS STRING) As longprivate declare function sendMessage lib "user32.dll" Alias "SendMessagea" (Byval Hwnd As Long, Byval WParam As Long, LParam as ring) AS Long
Private const bm_click = & hf5
Private Sub Command1_Click () Dim lPHWnd As Long, lCHWnd1 As Long, lCHWnd2 As Long, lCHWndA As Long, lCHWndE As Long lPHWnd = FindWindow (vbNullString, "calculator") lCHWnd1 = FindWindowEx (lPHWnd, ByVal 0 &, vbNullString, "1" ) lCHWnd2 = FindWindowEx (lPHWnd, ByVal 0 &, vbNullString, "2") lCHWndA = FindWindowEx (lPHWnd, ByVal 0 &, vbNullString, " ") lCHWndE = FindWindowEx (lPHWnd, ByVal 0 &, vbNullString, "=") SendMessage lCHWnd1, BM_CLICK , 0, 0 SendMessage Lchwnda, BM_Click, 0, 0 SendMessage Lchwnd2, BM_Click, 0, 0 SendMessage Lchwnde, BM_Click, 0, 0 End Sub