我正在使用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;
}
}