This commit is contained in:
fofolee 2020-04-21 18:31:46 +08:00
parent bd3f352cbe
commit 83c4551573
398 changed files with 120 additions and 120 deletions

0
.gitignore vendored Normal file → Executable file
View File

BIN
QuickCommand-1.5.1.upx Normal file

Binary file not shown.

View File

View File

3
README.md → src/README.md Normal file → Executable file
View File

@ -12,6 +12,9 @@
#### v1.5.0
- 注意本次更新对多处代码进行了重写,如果原有命令在上一版运行正常,在这一版出现了一些问题,请重新编辑该命令,修改命令的模式。如原有命令中使用了{{input}}变量的,关键字会变成[object object],请重新编辑该命令,将命令调整为`主输入框正则匹配`,如果原有命令中使用了{{pwd}}等变量的,请重新编辑该命令,将命令调整为`通过uTools呼出前的窗口匹配`
- 原先命令自定了图标的,如果图标显示异常,重新选择设置一次图标即可
##### 功能更新
- 新增`通过uTools呼出前的窗口匹配`的模式,现在可以快速编写一个应用到当前活动窗口的脚本

235
assets/index.js → src/assets/index.js Normal file → Executable file
View File

@ -1,118 +1,117 @@
utools.onPluginEnter( async ({ code, type, payload }) => {
// checkUpdate();
// 配置页面
if (code == 'options') {
utools.setExpendHeight(600);
$("#out").hide().html('');
$("#options").show();
showOptions();
} else {
$("#options").hide();
$("#out").show().text('');
var db = utools.db.get('customFts').data[code],
cmd = db.cmd;
if (db.program == "custom") {
option = db.customOptions;
} else {
option = programs[db.program];
}
// 正则
if (type == 'regex') cmd = cmd.replace(/\{\{input\}\}/mg, payload);
// 窗口
if (type == 'window') {
// 获取选中的文件
if (cmd.includes('{{SelectFile}}')) {
let repl = await getSelectFile(payload.id);
cmd = cmd.replace(/\{\{SelectFile\}\}/mg, repl)
}
// 获取资源管理器或访达当前目录
if (cmd.includes('{{pwd}}')) {
let repl = await pwd(payload.id);
cmd = cmd.replace(/\{\{pwd\}\}/mg, repl)
}
// 获取窗口信息
if (cmd.includes('{{WindowInfo}}')) {
let repl = JSON.stringify(payload);
cmd = cmd.replace(/\{\{WindowInfo\}\}/mg, repl)
}
}
// 无输出的批处理
// if (db.output == 'ignore' && option.ext == 'bat') option.bin = 'explorer';
if (db.hasSubInput) {
// 启动子命令输入
// 清空输出
$("#out").text('');
var subinput = '';
var setSubInput = () => {
utools.setSubInput(({text}) => {
subinput = text;
}, '');
}
var handleEnter = (event) => {
if (event.keyCode == 13) {
$("#out").text('');
var execmd = cmd.replace(/\{\{subinput\}\}/mg, subinput);
runCmd(execmd, option, db.codec, db.output);
}
};
setSubInput();
document.addEventListener('keydown', handleEnter);
// 移除监听
utools.onPluginOut(() => {
document.removeEventListener('keydown', handleEnter);
})
} else {
runCmd(cmd, option, db.codec, db.output);
}
}
});
function runCmd(cmd, option, codec, output) {
// 不需要输出的,提前关闭窗口
if (['ignore', 'clip', 'send', 'notice', 'terminal'].indexOf(output) !== -1){
utools.hideMainWindow()
utools.outPlugin()
}
var terminal = false;
if(output == 'terminal') terminal = true;
// 运行脚本
window.run(cmd, option, codec, terminal, (stdout, stderr) => {
if (stderr) {
// 报错
window.messageBox({ type: 'error', icon: window.logo, message: stderr, buttons: ['啊嘞?!'] })
utools.outPlugin()
} else if (stdout) {
// 有输出
switch (output) {
case "text":
$("#out").text(stdout);
break;
case "html":
$("#out").html(stdout);
break;
case "clip":
copyTo(stdout);
break;
case "send":
// 暂存用户剪贴板
var historyData = storeClip();
copyTo(stdout);
paste();
setTimeout(() => {
restoreClip(historyData);
}, 500);
break;
case "notice":
// 发送系统通知
utools.showNotification(stdout, null, true);
break;
case "ignore":
default:
break;
}
} else {
// 无输出
utools.outPlugin()
}
})
}
utools.onPluginEnter( async ({ code, type, payload }) => {
// 配置页面
if (code == 'options') {
utools.setExpendHeight(600);
$("#out").hide().html('');
$("#options").show();
showOptions();
} else {
$("#options").hide();
$("#out").show().text('');
var db = utools.db.get('customFts').data[code],
cmd = db.cmd;
if (db.program == "custom") {
option = db.customOptions;
} else {
option = programs[db.program];
}
// 正则
if (type == 'regex') cmd = cmd.replace(/\{\{input\}\}/mg, payload);
// 窗口
if (type == 'window') {
// 获取选中的文件
if (cmd.includes('{{SelectFile}}')) {
let repl = await getSelectFile(payload.id);
cmd = cmd.replace(/\{\{SelectFile\}\}/mg, repl)
}
// 获取资源管理器或访达当前目录
if (cmd.includes('{{pwd}}')) {
let repl = await pwd(payload.id);
cmd = cmd.replace(/\{\{pwd\}\}/mg, repl)
}
// 获取窗口信息
if (cmd.includes('{{WindowInfo}}')) {
let repl = JSON.stringify(payload);
cmd = cmd.replace(/\{\{WindowInfo\}\}/mg, repl)
}
}
// 无输出的批处理
// if (db.output == 'ignore' && option.ext == 'bat') option.bin = 'explorer';
if (db.hasSubInput) {
// 启动子命令输入
// 清空输出
$("#out").text('');
var subinput = '';
var setSubInput = () => {
utools.setSubInput(({text}) => {
subinput = text;
}, '');
}
var handleEnter = (event) => {
if (event.keyCode == 13) {
$("#out").text('');
var execmd = cmd.replace(/\{\{subinput\}\}/mg, subinput);
runCmd(execmd, option, db.codec, db.output);
}
};
setSubInput();
document.addEventListener('keydown', handleEnter);
// 移除监听
utools.onPluginOut(() => {
document.removeEventListener('keydown', handleEnter);
})
} else {
runCmd(cmd, option, db.codec, db.output);
}
}
});
function runCmd(cmd, option, codec, output) {
// 不需要输出的,提前关闭窗口
if (['ignore', 'clip', 'send', 'notice', 'terminal'].indexOf(output) !== -1){
utools.hideMainWindow()
utools.outPlugin()
}
var terminal = false;
if(output == 'terminal') terminal = true;
// 运行脚本
window.run(cmd, option, codec, terminal, (stdout, stderr) => {
if (stderr) {
// 报错
window.messageBox({ type: 'error', icon: window.logo, message: stderr, buttons: ['啊嘞?!'] })
utools.outPlugin()
} else if (stdout) {
// 有输出
switch (output) {
case "text":
$("#out").text(stdout);
break;
case "html":
$("#out").html(stdout);
break;
case "clip":
copyTo(stdout);
break;
case "send":
// 暂存用户剪贴板
var historyData = storeClip();
copyTo(stdout);
paste();
setTimeout(() => {
restoreClip(historyData);
}, 500);
break;
case "notice":
// 发送系统通知
utools.showNotification(stdout, null, true);
break;
case "ignore":
default:
break;
}
} else {
// 无输出
utools.outPlugin()
}
})
}

0
assets/jquery-3.3.1.min.js → src/assets/jquery-3.3.1.min.js vendored Normal file → Executable file
View File

0
assets/options.css → src/assets/options.css Normal file → Executable file
View File

0
assets/options.js → src/assets/options.js Normal file → Executable file
View File

View File

0
codemirror/.gitattributes → src/codemirror/.gitattributes vendored Normal file → Executable file
View File

0
codemirror/.npmignore → src/codemirror/.npmignore Normal file → Executable file
View File

0
codemirror/.travis.yml → src/codemirror/.travis.yml Normal file → Executable file
View File

0
codemirror/AUTHORS → src/codemirror/AUTHORS Normal file → Executable file
View File

View File

View File

0
codemirror/LICENSE → src/codemirror/LICENSE Normal file → Executable file
View File

0
codemirror/README.md → src/codemirror/README.md Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

0
codemirror/addon/lint/lint.js → src/codemirror/addon/lint/lint.js vendored Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

0
codemirror/addon/tern/tern.js → src/codemirror/addon/tern/tern.js vendored Normal file → Executable file
View File

View File

View File

View File

0
codemirror/bin/lint → src/codemirror/bin/lint Normal file → Executable file
View File

0
codemirror/bin/release → src/codemirror/bin/release Normal file → Executable file
View File

View File

Some files were not shown because too many files have changed in this diff Show More