1

我正在使用Global MouseKeyHook来监听鼠标点击和按键,同时在 VLC activeX 控件中播放视频。鼠标点击监听器触发良好,并按预期工作。但是按键/按下监听器不会触发。我附上了下面的一些代码,任何帮助将不胜感激。

订阅活动

    public void playVideo(string videoPath, bool loop)
    {
        stopTriggered = false;

        this.loop = loop;
        this.videoPath = videoPath;
        this.WindowState = FormWindowState.Normal;
        this.BringToFront();

        m_GolbalHook = Hook.GlobalEvents();
        m_GolbalHook.MouseClick += m_GolbalHook_MouseClick;
        m_GolbalHook.KeyDown += m_GolbalHook_KeyDown;

        axVLCPlugin21.Focus();
        axVLCPlugin21.playlist.items.clear();
        axVLCPlugin21.playlist.add("file:///" + videoPath);
        axVLCPlugin21.AutoLoop = loop;
        axVLCPlugin21_Pos = ScreenPositons.Screen1_Start;

        axVLCPlugin21.playlist.play();
    }

事件触发代码

    private void m_GolbalHook_KeyDown(object sender, KeyEventArgs e)
    {
        //Not triggering at the moment
        switch (e.KeyCode)
        {
            case Keys.Right:
                shiftRight();
                break;
            case Keys.Left:
                shiftLeft();
                break;
        }
    }
4

1 回答 1

0

发布我使用的解决方案,以防它帮助其他人。所有功劳归功于 Kilazur(见评论)。这不是一个完美的解决方案,但它的工作...

m_GolbalHook = Hook.GlobalEvents();
m_GolbalHook.MouseClick += m_GolbalHook_MouseClick;

m_AppHook = Hook.AppEvents();
m_AppHook.KeyDown += m_AppHook_KeyDown;

Hook.GlobalEvents()用于鼠标侦听器和Hook.AppEvents()按键侦听器。

于 2015-08-21T10:12:20.100 回答