From 6af4a15e2a00eca6392b89016c83b2fc8f673f91 Mon Sep 17 00:00:00 2001 From: fofolee Date: Wed, 8 Jan 2025 15:05:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=8F=91=E9=80=81=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E4=BB=8E=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E7=A7=BB=E5=88=B0?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E6=93=8D=E4=BD=9C=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E7=B2=98=E8=B4=B4=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/lib/quickcomposer/simulate/index.js | 2 + plugin/lib/quickcomposer/simulate/sendText.js | 11 +++ src/js/composer/commands/notifyCommands.js | 14 +--- src/js/composer/commands/simulateCommands.js | 69 +++++++++++++------ 4 files changed, 62 insertions(+), 34 deletions(-) create mode 100644 plugin/lib/quickcomposer/simulate/sendText.js diff --git a/plugin/lib/quickcomposer/simulate/index.js b/plugin/lib/quickcomposer/simulate/index.js index e191b83..f7a3847 100644 --- a/plugin/lib/quickcomposer/simulate/index.js +++ b/plugin/lib/quickcomposer/simulate/index.js @@ -1,7 +1,9 @@ const { findImage } = require("./imageFinder"); const { captureScreen } = require("./screenCapture"); +const sendText = require("./sendText"); module.exports = { findImage, captureScreen, + sendText, }; diff --git a/plugin/lib/quickcomposer/simulate/sendText.js b/plugin/lib/quickcomposer/simulate/sendText.js new file mode 100644 index 0000000..fc83990 --- /dev/null +++ b/plugin/lib/quickcomposer/simulate/sendText.js @@ -0,0 +1,11 @@ +const sendText = (text, simulateCopy = false) => { + if (simulateCopy) { + window.utools.copyText(text); + quickcommand.sleep(200); + quickcommand.simulatePaste(); + } else { + window.utools.hideMainWindowTypeString(text); + } +}; + +module.exports = sendText; diff --git a/src/js/composer/commands/notifyCommands.js b/src/js/composer/commands/notifyCommands.js index a741374..09a9675 100644 --- a/src/js/composer/commands/notifyCommands.js +++ b/src/js/composer/commands/notifyCommands.js @@ -5,7 +5,7 @@ export const notifyCommands = { commands: [ { value: "console.log", - label: "打印消息", + label: "显示消息", config: [ { key: "log", @@ -27,17 +27,5 @@ export const notifyCommands = { }, ], }, - { - value: "utools.hideMainWindowTypeString", - label: "发送文本到活动窗口", - config: [ - { - key: "text", - label: "要发送到窗口的文本内容", - type: "varInput", - icon: "send", - }, - ], - }, ], }; diff --git a/src/js/composer/commands/simulateCommands.js b/src/js/composer/commands/simulateCommands.js index 646661c..2eb3e52 100644 --- a/src/js/composer/commands/simulateCommands.js +++ b/src/js/composer/commands/simulateCommands.js @@ -9,10 +9,33 @@ export const simulateCommands = { config: [], component: "KeyEditor", }, + { + value: "quickcomposer.simulate.sendText", + label: "发送文本", + config: [ + { + key: "text", + label: "要发送的文本内容", + type: "varInput", + icon: "send", + width: 9, + }, + { + label: "发送方式", + type: "select", + defaultValue: false, + icon: "keyboard", + options: [ + { label: "模拟输入", value: false }, + { label: "模拟粘贴", value: true }, + ], + width: 3, + }, + ], + }, { value: "utools.simulateMouseClick", label: "鼠标点击", - allowEmptyArgv: true, config: [ { label: "X坐标(留空则原地点击)", @@ -47,32 +70,36 @@ export const simulateCommands = { }, { value: "utools.simulateMouseMove", - label: "鼠标移动", - config: [ + label: "鼠标位置", + functionSelector: [ { - label: "X坐标", - icon: "drag_handle", - defaultValue: 0, - type: "numInput", - width: 6, + label: "移动到坐标", + value: "utools.simulateMouseMove", + icon: "mouse", + config: [ + { + label: "X坐标", + icon: "drag_handle", + defaultValue: 0, + type: "numInput", + width: 6, + }, + { + label: "Y坐标", + icon: "drag_handle", + defaultValue: 0, + type: "numInput", + width: 6, + }, + ], }, { - label: "Y坐标", - icon: "drag_handle", - defaultValue: 0, - type: "numInput", - width: 6, + label: "获取坐标", + value: "utools.getCursorScreenPoint", + icon: "mouse", }, ], }, - { - value: "utools.getCursorScreenPoint", - label: "获取鼠标坐标", - outputVariable: "{x:curX,y:curY}", - saveOutput: true, - config: [], - allowEmptyArgv: true, - }, { value: "quickcomposer.simulate.findImage", label: "屏幕找图",