CSDN博客

img lxcc

API操作其他程序中的按钮

发表于2004/10/20 23:14:00  832人阅读

分类: VB

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.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) 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, "计算器")
    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

阅读全文
0 0

相关文章推荐

img
取 消
img