diff --git a/plugin/lib/quickcomposer/simulate/index.js b/plugin/lib/quickcomposer/simulate/index.js index f7a3847..e4bce25 100644 --- a/plugin/lib/quickcomposer/simulate/index.js +++ b/plugin/lib/quickcomposer/simulate/index.js @@ -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, }; diff --git a/plugin/lib/quickcomposer/simulate/keyboardTap.js b/plugin/lib/quickcomposer/simulate/keyboardTap.js new file mode 100644 index 0000000..3b239bf --- /dev/null +++ b/plugin/lib/quickcomposer/simulate/keyboardTap.js @@ -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 }; diff --git a/src/components/composer/simulate/KeyEditor.vue b/src/components/composer/simulate/KeyEditor.vue index 89ee876..9371ff4 100644 --- a/src/components/composer/simulate/KeyEditor.vue +++ b/src/components/composer/simulate/KeyEditor.vue @@ -51,7 +51,52 @@ @@ -104,11 +149,250 @@ + + diff --git a/src/js/composer/cardComponents.js b/src/js/composer/cardComponents.js index 1ed8732..c919a92 100644 --- a/src/js/composer/cardComponents.js +++ b/src/js/composer/cardComponents.js @@ -1,14 +1,17 @@ import { defineAsyncComponent } from "vue"; -// UI Components +// 模拟操作组件 export const KeyEditor = defineAsyncComponent(() => import("src/components/composer/simulate/KeyEditor.vue") ); export const ImageSearchEditor = defineAsyncComponent(() => import("components/composer/simulate/ImageSearchEditor.vue") ); +export const KeySequenceEditor = defineAsyncComponent(() => + import("src/components/composer/simulate/KeySequenceEditor.vue") +); -// Control Flow Components +// 控制流组件 export const ConditionalJudgment = defineAsyncComponent(() => import("components/composer/control/ConditionalJudgment.vue") ); @@ -31,18 +34,24 @@ export const TryCatchControl = defineAsyncComponent(() => import("components/composer/control/TryCatchControl.vue") ); -// Editor Components +// 网络组件 export const UBrowserEditor = defineAsyncComponent(() => import("components/composer/ubrowser/UBrowserEditor.vue") ); export const AxiosConfigEditor = defineAsyncComponent(() => import("src/components/composer/network/AxiosConfigEditor.vue") ); + +// 数据组件 export const RegexEditor = defineAsyncComponent(() => import("components/composer/data/regex/RegexEditor.vue") ); -// Crypto Components +export const ZlibEditor = defineAsyncComponent(() => + import("src/components/composer/data/ZlibEditor.vue") +); + +// 加密组件 export const SymmetricCryptoEditor = defineAsyncComponent(() => import("src/components/composer/coding/SymmetricCryptoEditor.vue") ); @@ -50,20 +59,17 @@ export const AsymmetricCryptoEditor = defineAsyncComponent(() => import("src/components/composer/coding/AsymmetricCryptoEditor.vue") ); -// File Components +// 文件组件 export const FileOperationEditor = defineAsyncComponent(() => import("components/composer/file/FileOperationEditor.vue") ); -// System Components +// 系统组件 export const SystemCommandEditor = defineAsyncComponent(() => import("components/composer/system/SystemCommandEditor.vue") ); -export const ZlibEditor = defineAsyncComponent(() => - import("src/components/composer/data/ZlibEditor.vue") -); - +// UI组件 export const SelectListEditor = defineAsyncComponent(() => import("components/composer/ui/SelectListEditor.vue") ); diff --git a/src/js/composer/commands/index.js b/src/js/composer/commands/index.js index c2f1fe8..41d362d 100644 --- a/src/js/composer/commands/index.js +++ b/src/js/composer/commands/index.js @@ -10,12 +10,14 @@ import { uiCommands } from "./uiCommands"; import { codingCommands } from "./codingCommand"; import { mathCommands } from "./mathCommands"; import { userdataCommands } from "./userdataCommands"; +import { utoolsCommands } from "./utoolsCommand"; export const commandCategories = [ fileCommands, networkCommands, systemCommands, notifyCommands, + utoolsCommands, dataCommands, codingCommands, controlCommands, diff --git a/src/js/composer/commands/otherCommands.js b/src/js/composer/commands/otherCommands.js index 510066f..b7edf86 100644 --- a/src/js/composer/commands/otherCommands.js +++ b/src/js/composer/commands/otherCommands.js @@ -3,18 +3,6 @@ export const otherCommands = { icon: "more_horiz", defaultOpened: false, commands: [ - { - value: "utools.redirect", - label: "转至指定插件", - config: [ - { - key: "pluginName", - label: "要跳转至的插件名称", - type: "varInput", - icon: "alt_route", - }, - ], - }, { value: "quickcommand.sleep", label: "添加延时", diff --git a/src/js/composer/commands/simulateCommands.js b/src/js/composer/commands/simulateCommands.js index 2eb3e52..e3dc683 100644 --- a/src/js/composer/commands/simulateCommands.js +++ b/src/js/composer/commands/simulateCommands.js @@ -4,11 +4,34 @@ export const simulateCommands = { defaultOpened: false, commands: [ { - value: "utools.simulateKeyboardTap", + value: "quickcomposer.simulate.keyboardTap", label: "模拟按键", config: [], component: "KeyEditor", }, + { + value: "quickcomposer.simulate.keySequence", + label: "按键序列", + description: "按顺序执行多个按键操作", + component: "KeySequenceEditor", + }, + { + value: "quickcommand.simulateCopy", + label: "模拟复制粘贴", + config: [], + functionSelector: [ + { + value: "quickcommand.simulateCopy", + label: "复制", + icon: "content_copy", + }, + { + value: "quickcommand.simulatePaste", + label: "粘贴", + icon: "content_paste", + }, + ], + }, { value: "quickcomposer.simulate.sendText", label: "发送文本", diff --git a/src/js/composer/commands/systemCommands.js b/src/js/composer/commands/systemCommands.js index 62b321a..64b1b4a 100644 --- a/src/js/composer/commands/systemCommands.js +++ b/src/js/composer/commands/systemCommands.js @@ -1,3 +1,5 @@ +import { newVarInputVal } from "js/composer/varInputValManager"; + export const systemCommands = { label: "系统操作", icon: "computer", @@ -299,5 +301,26 @@ export const systemCommands = { }, ], }, + { + value: "quickcommand.kill", + label: "关闭进程", + desc: "关闭指定进程", + icon: "dangerous", + config: [ + { + label: "进程ID", + type: "numInput", + icon: "developer_board", + width: 6, + }, + { + label: "信号", + type: "varInput", + icon: "signal_cellular_alt", + defaultValue: newVarInputVal("str", "SIGTERM"), + width: 6, + }, + ], + }, ], }; diff --git a/src/js/composer/commands/utoolsCommand.js b/src/js/composer/commands/utoolsCommand.js new file mode 100644 index 0000000..518afcf --- /dev/null +++ b/src/js/composer/commands/utoolsCommand.js @@ -0,0 +1,87 @@ +export const utoolsCommands = { + label: "uTools功能", + icon: "insights", + commands: [ + { + value: "utools.hideMainWindow", + label: "隐藏主窗口", + desc: "隐藏主窗口", + icon: "visibility_off", + }, + { + value: "quickcommand.wakeUtools", + label: "唤醒uTools", + desc: "唤醒uTools", + icon: "visibility", + }, + { + value: "utools.setExpendHeight", + label: "设置uTools高度", + desc: "设置uTools高度", + icon: "height", + config: [ + { + key: "height", + label: "高度", + type: "numInput", + icon: "straighten", + width: 12, + }, + ], + }, + { + value: "utools.outPlugin", + label: "退出插件", + desc: "退出插件", + icon: "exit_to_app", + config: [ + { + key: "isKill", + type: "select", + options: [ + { label: "杀死插件进程", value: true }, + { label: "插件隐藏到后台", value: false }, + ], + defaultValue: false, + icon: "logout", + }, + ], + }, + { + value: "utools.isDarkColors", + label: "是否深色模式", + desc: "是否深色模式", + icon: "dark_mode", + outputVariable: "isDark", + saveOutput: true, + }, + { + value: "utools.getUser", + label: "获取用户信息", + desc: "获取用户信息", + icon: "person", + outputVariable: "{avatar,nickname,type}", + saveOutput: true, + }, + { + value: "utools.redirect", + label: "转至指定插件", + config: [ + { + key: "pluginName", + label: "要跳转至的插件名称", + type: "varInput", + icon: "alt_route", + width: 6, + }, + { + key: "payload", + label: "传递给插件的文本", + type: "varInput", + icon: "alt_route", + width: 6, + }, + ], + }, + ], +};