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: "屏幕找图",