Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const MK_LBUTTON = &H1Private Sub Command1_Click()
    Call MC(100, 100)
End SubFunction MC(ByVal X As Long, Y As Long) '模拟鼠标单击函数
    Dim lParam As Long
    X = X1
    Y = Y1 * &H10000
    wbhwnd = Form1.hwnd
    MsgBox wbhwnd
    
    k = PostMessage(wbhwnd, WM_LBUTTONDOWN, MK_LBUTTON, ByVal ((Y) + X))
    k = PostMessage(wbhwnd, WM_LBUTTONUP, 0, (X + (Y)))
End Function

解决方案 »

  1.   

    Private Function SendClick(hwnd As Long, mX As Long, mY As Long) 
         '发送点击消息 
        Dim I As Long 
         
        I = PostMessage(hwnd, WM_LBUTTONDOWN, 0, (mX And &HFFFF) + (mY And &HFFFF) * &H10000) 
        I = PostMessage(hwnd, WM_LBUTTONUP, 0, (mX And &HFFFF) + (mY And &HFFFF) * &H10000) 
    End Function
    试试
      

  2.   

    Dim lngP As Long
        lngP = PostMessage(lngButton_1_Hwnd, WM_LBUTTONDOWN, &H0, &H0) '按下鼠标左键
        lngP = PostMessage(lngButton_1_Hwnd, WM_LBUTTONUP, &H0, &H0)   '松开鼠标左键
      

  3.   

    Private Sub Command1_Click()
    Picture1.Cls
    ClickHwndByXy Picture1.Hwnd, 20, 20End SubPrivate Sub Form_Load()
    '窗体上添加一个按钮控件和图片框控件就可以了
    Picture1.DrawWidth = 25
    Picture1.ForeColor = vbRed
    End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     Picture1.PSet (X, Y)
    If Button = 1 Then
    MsgBox "坐标被点击:" & X & "--" & Y & ",像素:" & X / Screen.TwipsPerPixelX & "," & Y / Screen.TwipsPerPixelY
    End If
    End Sub
      

  4.   

    Private Sub Command1_Click()
    Picture1.Cls
    ClickHwndByXy Picture1.Hwnd, 20, 20End SubPrivate Sub Form_Load()
    '窗体上添加一个按钮控件和图片框控件就可以了
    Picture1.DrawWidth = 25
    Picture1.ForeColor = vbRed
    End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     Picture1.PSet (X, Y)
    If Button = 1 Then
    MsgBox "坐标被点击:" & X & "--" & Y & ",像素:" & X / Screen.TwipsPerPixelX & "," & Y / Screen.TwipsPerPixelY
    End If
    End Sub
      

  5.   

    Private Sub Command1_Click()
    Picture1.Cls
    ClickHwndByXy Picture1.Hwnd, 20, 20End SubPrivate Sub Form_Load()
    '窗体上添加一个按钮控件和图片框控件就可以了
    Picture1.DrawWidth = 25
    Picture1.ForeColor = vbRed
    End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     Picture1.PSet (X, Y)
    If Button = 1 Then
    MsgBox "坐标被点击:" & X & "--" & Y & ",像素:" & X / Screen.TwipsPerPixelX & "," & Y / Screen.TwipsPerPixelY
    End If
    End Sub