你可以定义mouse事件的hook函数,参数中有窗口的局柄,一定要用dll来做,这样代码才能注入到对方应用程序中。

解决方案 »

  1.   

    heng_s: 你是在本程序里用还是,对任意的一个窗体来说,如果是对任意窗体,只要知道控件的句柄,用GetWindowText()即可获得。
    具体使用程序如下:Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
    Private Sub Form_Activate()
        Dim MyStr As String
        'Create a buffer
        MyStr = String(100, Chr$(0))
        'Get the windowtext
        GetWindowText Me.hwnd, MyStr, 100
        'strip the rest of buffer
        MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1)
        'Triple the window's text
        MyStr = MyStr + MyStr + MyStr
        'Set the new window text
        SetWindowText Me.hwnd, MyStr
    End Sub如果想获得任意控件的句柄也很简单,不知是否感兴趣:)
    用GetCursorPos()和WindowFromPoint()实现。