Win10 Node.js执行同步错误
我正在尝试创建一个简单的bot,它能够在我的PC上检测到某些事件发生的时间(我知道node.js不是最好的解决方案,但我只是想看看我能用node.js做些什么) 我使用Win10 Node.js执行同步错误,node.js,windows,imagemagick,Node.js,Windows,Imagemagick,我正在尝试创建一个简单的bot,它能够在我的PC上检测到某些事件发生的时间(我知道node.js不是最好的解决方案,但我只是想看看我能用node.js做些什么) 我使用nircmdc.exe截图并裁剪出一个特定区域。我想将该区域与ImageMagick进行比较,并使用node.js脚本进行其他操作,但我仍停留在第一部分 我的剧本: var child_process = require('child_process'); var output = child_process.execSync('
nircmdc.exe
截图并裁剪出一个特定区域。我想将该区域与ImageMagick进行比较,并使用node.js脚本进行其他操作,但我仍停留在第一部分
我的剧本:
var child_process = require('child_process');
var output = child_process.execSync('compare.exe -metric mse "images/screenGrab.jpg" "images/knownRegion.jpg" null').toString();
console.log(output);
console.log('Done!');
如果使用相同的图像,则不会出现错误:
D:\app\nodejs>node compareRegion.js
0 (0)
Done!
但是,如果我使用不同的图像,我仍然可以看到输出,但是node.js会因错误而失败
D:\app\nodejs>node compareRegion.js
12660.3 (0.193184)child_process.js:526
throw err;
^
Error: Command failed: compare.exe -metric mse "images/screenGrab.jpg" "images/knownRegion.jpg" null
12660.3 (0.193184)
at checkExecSyncError (child_process.js:483:13)
at Object.execSync (child_process.js:523:13)
at Object.<anonymous> (D:\app\nodejs\compareRegion.js:30:28)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
D:\app\nodejs>node compareRegion.js
12660.3(0.193184)child_process.js:526
犯错误;
^
错误:命令失败:compare.exe-metric mse“images/screenGrab.jpg”“images/knownRegion.jpg”null
12660.3 (0.193184)
在checkExecSyncError(child_process.js:483:13)
在Object.execSync(child_process.js:523:13)
反对。(D:\app\nodejs\compareRegion.js:30:28)
在模块处编译(Module.js:556:32)
在Object.Module._extensions..js(Module.js:565:10)
在Module.load(Module.js:473:32)
在TryModule加载时(module.js:432:12)
在Function.Module.\u加载(Module.js:424:3)
位于Module.runMain(Module.js:590:10)
运行时(bootstrap_node.js:394:7)
我可以看到结果12660.3(0.193184)
,但脚本随后失败
有没有一种方法可以在结果出来时抑制此错误,或者执行其他操作?。。Dunno,第一次使用node.js:)