如何调用具有MouseEventArgs的方法?

时间:2018-12-10 15:57:18

标签: c# methods dll hook mouse

我已经挣扎了一段时间。我有一个可检测鼠标移动的钩子,因此无法重复调用它。它只是给我错误,我不知道如何称呼它。这是代码

private IKeyboardMouseEvents m_GlobalHook;

    public int x;
    public int y;



    public void Subscribe()
    {
        // Note: for the application hook, use the Hook.AppEvents() instead
        m_GlobalHook = Hook.GlobalEvents();

        m_GlobalHook.MouseDownExt += GlobalHookMouseDownExt;
        m_GlobalHook.KeyPress += GlobalHookKeyPress;
    }

    public void Unsubscribe()
    {
        m_GlobalHook.MouseDownExt -= GlobalHookMouseDownExt;
        m_GlobalHook.KeyPress -= GlobalHookKeyPress;

        //It is recommened to dispose it
        m_GlobalHook.Dispose();
    }



    private bool mouseDown;
    private Point lastLocation;

    public Form1()
    {
        InitializeComponent();

    }


    private void GlobalHookKeyPress(object sender, KeyPressEventArgs e)
    {

    }

    private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
    {
        label7.Text = "IsDown: Yes";
        this.Cursor = new Cursor(Cursor.Current.Handle);
        Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + trackBar1.Value);
        GlobalHookMouseDownExt; // This thing doesn't work, no matter if I use brackets or not to call it, it just doesn't work.
    }

此外,如果我输入null,则为null。我得到stackoverflowexception。

0 个答案:

没有答案