补全屏幕截图、屏幕取色、获取显示器信息、剪贴板操作

This commit is contained in:
fofolee
2025-01-09 22:43:33 +08:00
parent 682f6d0bcd
commit 378ae7f92f
10 changed files with 420 additions and 83 deletions

View File

@@ -11,6 +11,7 @@ import { codingCommands } from "./codingCommand";
import { mathCommands } from "./mathCommands";
import { userdataCommands } from "./userdataCommands";
import { utoolsCommands } from "./utoolsCommand";
import { screenCommands } from "./screenCommands";
export const commandCategories = [
fileCommands,
@@ -25,5 +26,6 @@ export const commandCategories = [
simulateCommands,
mathCommands,
userdataCommands,
screenCommands,
otherCommands,
];

View File

@@ -0,0 +1,126 @@
import { newVarInputVal } from "js/composer/varInputValManager";
const XY_DICT_EDITOR = {
label: "坐标",
type: "dictEditor",
icon: "transform",
isCollapse: false,
width: 12,
defaultValue: {
x: newVarInputVal("var", "0"),
y: newVarInputVal("var", "0"),
},
options: {
fixedKeys: [
{ value: "x", label: "X坐标" },
{ value: "y", label: "Y坐标" },
],
disableAdd: true,
},
};
const RECT_DICT_EDITOR = {
label: "区域",
type: "dictEditor",
icon: "transform",
isCollapse: false,
width: 12,
defaultValue: {
x: newVarInputVal("var", "0"),
y: newVarInputVal("var", "0"),
width: newVarInputVal("var", "100"),
height: newVarInputVal("var", "100"),
},
options: {
fixedKeys: [
{ value: "x", label: "X坐标" },
{ value: "y", label: "Y坐标" },
{ value: "width", label: "宽度" },
{ value: "height", label: "高度" },
],
disableAdd: true,
},
};
export const screenCommands = {
label: "显示器",
icon: "screenshot_monitor",
commands: [
{
value: "utools.getPrimaryDisplay",
label: "获取显示器信息",
desc: "获取显示器信息",
icon: "monitor",
outputVariable: "display",
saveOutput: true,
subCommands: [
{
value: "utools.getPrimaryDisplay",
label: "获取主显示器",
icon: "monitor",
},
{
value: "utools.getAllDisplays",
label: "获取所有显示器",
icon: "desktop_windows",
},
{
value: "utools.getDisplayNearestPoint",
label: "获取位置所在显示器",
icon: "gps_fixed",
config: [XY_DICT_EDITOR],
},
{
value: "utools.getDisplayMatching",
label: "获取矩形所在显示器",
icon: "crop_square",
config: [RECT_DICT_EDITOR],
},
],
},
{
value: "utools.screenToDipPoint",
label: "物理/DIP坐标转换",
desc: "屏幕物理坐标和 DIP 坐标转换",
icon: "transform",
outputVariable: "{x,y}",
saveOutput: true,
config: [XY_DICT_EDITOR],
subCommands: [
{
value: "utools.screenToDipPoint",
label: "物理坐标转DIP坐标",
icon: "transform",
},
{
value: "utools.dipToScreenPoint",
label: "DIP坐标转物理坐标",
icon: "transform",
},
],
},
{
value: "utools.screenToDipRect",
label: "物理/DIP区域转换",
desc: "屏幕物理区域和 DIP 区域转换",
icon: "transform",
outputVariable: "{x,y,width,height}",
saveOutput: true,
config: [RECT_DICT_EDITOR],
subCommands: [
{
value: "utools.screenToDipRect",
label: "物理区域转DIP区域",
desc: "屏幕物理区域转 DIP 区域",
icon: "transform",
},
{
value: "utools.dipToScreenRect",
label: "DIP区域转物理区域",
desc: "DIP 区域转屏幕物理区域",
icon: "transform",
},
],
},
],
};

View File

@@ -1,3 +1,5 @@
import { newVarInputVal } from "js/composer/varInputValManager";
export const simulateCommands = {
label: "模拟操作",
icon: "ads_click",
@@ -185,5 +187,89 @@ export const simulateCommands = {
config: [],
isAsync: true,
},
{
value: "quickcomposer.simulate.screenColorPick",
label: "屏幕取色",
desc: "获取用户选择的颜色,会弹出一个系统取色器",
icon: "colorize",
isAsync: true,
outputVariable: "{hex,rgb}",
saveOutput: true,
},
{
value: "quickcomposer.simulate.captureScreen",
label: "屏幕截图",
desc: "屏幕截图,进行区域截图或全屏截图",
icon: "screenshot_monitor",
isAsync: true,
outputVariable: "base64Data",
saveOutput: true,
config: [
{
key: "range",
label: "截图范围",
type: "buttonGroup",
options: [
{
label: "全屏截图",
value: "fullscreen",
},
{
label: "区域截图",
value: "area",
},
],
defaultValue: "fullscreen",
width: 12,
},
],
subCommands: [
{
label: "保存到dataUrl",
value: "quickcomposer.simulate.captureScreen",
icon: "link",
},
{
label: "保存到文件",
value: "quickcomposer.simulate.captureScreenToFile",
icon: "file_copy",
config: [
{
key: "path",
label: "截图保存路径",
type: "varInput",
defaultValue: newVarInputVal(
"str",
`${window.utools.getPath("desktop")}${
utools.isWindows() ? "\\" : "/"
}quickcommand_screenshot.png`
),
options: {
dialog: {
type: "save",
options: {
title: "选择保存路径",
properties: ["openFile", "showHiddenFiles"],
filters: [
{
name: "PNG",
extensions: ["png"],
},
],
},
},
},
icon: "description",
width: 12,
},
],
},
{
label: "复制到剪贴板",
value: "quickcomposer.simulate.captureScreenToClipboard",
icon: "content_copy",
},
],
},
],
};

View File

@@ -6,20 +6,75 @@ export const systemCommands = {
defaultOpened: false,
commands: [
{
value: "electron.clipboard.writeText",
label: "将内容写入剪贴板",
config: [
value: "utools.copyText",
label: "写入剪贴板",
subCommands: [
{
key: "content",
label: "写入剪切板的内容",
type: "varInput",
value: "utools.copyText",
label: "写入文本",
icon: "content_copy",
config: [
{
key: "content",
label: "要写入剪切板的内容",
type: "varInput",
icon: "content_copy",
},
],
},
{
value: "utools.copyImage",
label: "写入图片",
icon: "image",
config: [
{
key: "image",
label: "图片路径/base64",
type: "varInput",
icon: "image",
options: {
dialog: {
type: "open",
options: {
title: "选择图片",
properties: ["openFile", "showHiddenFiles"],
},
},
},
},
],
},
{
value: "utools.copyFile",
label: "写入文件",
icon: "file_copy",
config: [
{
key: "file",
label: "文件路径",
type: "varInput",
icon: "file_copy",
options: {
dialog: {
type: "open",
options: {
title: "选择文件",
properties: [
"openFile",
"showHiddenFiles",
"multiSelections",
],
},
},
},
},
],
},
],
},
{
value: "electron.clipboard.readText",
label: "取剪贴板内容",
label: "取剪贴板",
outputVariable: "clipboardContent",
saveOutput: true,
subCommands: [
@@ -33,6 +88,11 @@ export const systemCommands = {
label: "剪贴板图片",
icon: "image",
},
{
value: "utools.getCopyedFiles",
label: "剪贴板文件",
icon: "file_copy",
},
{
value: "electron.clipboard.readRTF",
label: "剪贴板RTF",

View File

@@ -110,6 +110,7 @@ export const utoolsCommands = {
type: "dictEditor",
icon: "settings",
options: {
disableAdd: true,
fixedKeys: [
{
value: "forward",