let args = $engines.myEngine().execArgv;
let serverEngineId = args.serverEngineId;
let serverEngine = engines.all().find(e => {
return e.id === serverEngineId
});
if (!serverEngine) {
console.error('请运行文件"main.js",而不是直接启动本代码');
exit();
}
const window = $floaty.window(`<frame visibility="invisible" />`);
ui.run((function () {
window.requestFocus();
setTimeout((function () {
window.exitOnClose();
}), 200);
}));
const clip = getClip();
serverEngine.emit('clipAck', clip);
exit();
创建文件clip.float.js
export async function getClip(timeout: number = 3000) {
return new Promise<string | null>((resolve, reject) => {
const timeouter = setTimeout(() => {
resolve(null)
}, timeout)
myEngine().once(`clipAck`, (text) => {
clearTimeout(timeouter)
resolve(text)
})
execScriptFile(join(__dirname, 'clip.float.js'), {
arguments: {
serverEngineId: myEngine().id,
}
})
})
}
使用的是autojspro nodejs 语法
没有回复内容