electron linux环境下模拟物理键盘发送F11键
一、解题思路:
1、寻找linux模拟键盘发送F11命令
2、node js执行命令
二、方案:
1、安装xdotool
xdotool 是一个强大的 Linux 命令行工具,可以模拟键盘和鼠标输入。
sudo apt install xdotool # Debian/Ubuntu
2、发送F11的命令
xdotool key F11
3、electron里面执行命令
const { exec } = require('child_process');
function sendF11(){
try{
exec('xdotool key F11');
}
catch(e){
console.log("发送键盘异常")
}
}

浙公网安备 33010602011771号