模拟按键新增常用按键,模拟操作新增按键序列,系统操作新增关闭进程,新增uTools功能分类,添加部分命令

This commit is contained in:
fofolee
2025-01-09 01:01:15 +08:00
parent d2c3b7999c
commit b676801b9a
10 changed files with 1277 additions and 68 deletions

View File

@@ -1,9 +1,12 @@
const { findImage } = require("./imageFinder");
const { captureScreen } = require("./screenCapture");
const sendText = require("./sendText");
const { keyboardTap, keySequence } = require("./keyboardTap");
module.exports = {
findImage,
captureScreen,
sendText,
keyboardTap,
keySequence,
};

View File

@@ -0,0 +1,34 @@
const keyboardTap = (keys, options = {}) => {
const { repeatCount = 1, repeatInterval = 0, keyDelay = 0 } = options;
// 执行重复操作
const repeat = () => {
for (let i = 0; i < repeatCount; i++) {
// 执行按键操作
window.utools.simulateKeyboardTap(...keys);
// 如果有重复间隔且不是最后一次,则等待
if (repeatInterval > 0 && i < repeatCount - 1) {
quickcommand.sleep(repeatInterval);
}
}
// 如果有按键后延迟,则等待
if (keyDelay > 0) {
quickcommand.sleep(keyDelay);
}
};
return repeat();
};
const keySequence = (sequence, { interval = 100 } = {}) => {
sequence.forEach((keys, index) => {
keyboardTap(keys);
if (index < sequence.length - 1) {
quickcommand.sleep(interval);
}
});
};
module.exports = { keyboardTap, keySequence };