mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-09-23 20:44:42 +08:00
模拟按键新增常用按键,模拟操作新增按键序列,系统操作新增关闭进程,新增uTools功能分类,添加部分命令
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
34
plugin/lib/quickcomposer/simulate/keyboardTap.js
Normal file
34
plugin/lib/quickcomposer/simulate/keyboardTap.js
Normal 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 };
|
Reference in New Issue
Block a user