我尝试使用MouseX和MouseY变量作为对象来调用鼠标单击功能。我的调用看起来像这样:
Invoke(New SendClickInvoker(AddressOf Functions.SendRightClick), (TargetFind(0) + 15) - X, (TargetFind(1) + 35) - Y)
在班级里,我宣布了一个这样的代表:
Public Delegate Sub SendClickInvoker(ByVal X As Object, ByVal Y As Object)
然后我访问的函数看起来像这样:
Public Shared Sub SendRightClick(ByVal MouseX As String, ByVal MouseY As String)
Try
If Declares.Handle <> "" Then
Dim pos As IntPtr
Dim button As IntPtr = CUInt(&H2)
pos = getHiLoWord(MouseX, MouseY)
WinApi.SetForegroundWindow(Declares.Handle)
Threading.Thread.Sleep(150)
WinApi.PostMessage(Declares.Handle, &H204, button, pos)
Else
GetProcessInformation()
SendRightClick(MouseX, MouseY)
End If
Catch ex As Exception
MsgBox(ex.Message & " - Right Click")
End Try
End Sub
我得到这个例子“找不到类型整数的默认成员”。我究竟做错了什么?它适用于另一个从并行线程运行的调用,我无法发现差异。