我想要做的是跟踪键盘和鼠标事件以创建一个 TimeTracker,因为我正在使用 Iohook,它在 Windows 上工作得很好。下面是我的代码
// @ts-ignore
import * as Electron from "electron";
import { Connector } from "./connector";
import * as iohook from "iohook";
export class HookService extends Connector {
constructor(socket: SocketIO.Socket, public app: Electron.App) {
super(socket, app);
}
onHostReady(): void {
// execute your own JavaScript Host logic here
console.log("keyboard event");
this.on("abi", async() => {
iohook.start(true);
iohook.on('mousemove', event => {
console.log(event); // { type: 'mousemove', x: 700, y: 400 }
});
})
}
}
但是,当我尝试在 Ubuntu 16.04 中使用相同的代码实现相同目标时,我遇到了错误。
load_input_helper [1920]: XKB support is required to accurately determine keyboard characters!
keyboard event
stdout: ASP.NET Core host has fully started.
Hosting environment: Production
Content root path: /home/testingelectron/obj/Host/bin
Now listening on: http://localhost:8002
Application started. Press Ctrl+C to shut down.
/home/testingelectron/obj/Host/node_modules/electron/dist/electron ../../main.js: symbol lookup error: /home/testingelectron/obj/Host/ElectronHostHook/node_modules/iohook/builds/electron-v85-linux-x64/build/Release/uiohook.so: undefined symbol: xkb_x11_get_core_keyboard_device_id```
Also I did installed **sudo apt-get install -y libxkbcommon-x11-0** as mentioned <https://github.com/wilix-team/iohook>
thanks in advance.