我尝试使用 public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
MainWindow wnd = new MainWindow();
wnd.Show();
SetupKeyboardHooks();
}
#region KeyHooks
private GlobalKeyboardHook _globalKeyboardHook;
public void SetupKeyboardHooks()
{
_globalKeyboardHook = new GlobalKeyboardHook();
_globalKeyboardHook.KeyboardPressed += OnKeyPressed;
}
private void OnKeyPressed(object sender, GlobalKeyboardHookEventArgs e)
{
//TODO: if device is barcode scanner do {x}... else do {y} ....
if (e.KeyboardData.VirtualCode == 65) //ignore the "a" key
e.Handled = true;
}
public void Dispose()
{
_globalKeyboardHook.Dispose();
}
#endregion
}
来获取元素,但是总是出现错误:无法找到元素。有什么建议吗?请帮助!您可以参考我的代码非常感谢!
cssSelector