在我的程序中检测到PInvokeStackImbalance

时间:2017-08-24 06:43:11

标签: vb.net

我尝试获取在计时器工作期间鼠标单击的坐标。 但是因为“检测到PInvokeStackImbalance”而出现错误。 你怎么摆脱这个错误? 部分程序如下。

在这里输入代码

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
Public Const MOUSEEVENTF_MIDDLEUP = &H40
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10
Dim Mouse_LeftClick As Boolean

Private Sub TimerRec_Tick(sender As Object, e As EventArgs) Handles TimerRec.Tick

    Mouse_LeftClick = GetAsyncKeyState(Keys.LButton) ' **error occured here!**
    If Mouse_LeftClick Then
        Messagebox.show(MousePosition.X.ToString & " " & MousePosition.Y.ToString)
    End If



End Sub

0 个答案:

没有答案