我正在使用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;
}
}
答案 0 :(得分: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()
作为密钥监听器。