首页 > 如何使用Native Messaging API 打开window程序

如何使用Native Messaging API 打开window程序

我参照François Beaufort的视频写了一个打开CMD程序的chrome应用,但是没效果,应该已调用到用于打开程序的本地应用了,但是似乎terminal.bat没有执行。
视频链接:https://www.youtube.com/watch?feature...

我的代码:
添加到chrome的应用

//**background.js**
//On click connect to the native terminal app
chrome.browserAction.onClicked.addListener(function () {
    chrome.extension.connectNative('terminal');
});
//**manifest.json**
{
    "name": "My extension",
    "version": "0.1",
    "background": {
        "scripts": [ "background.js" ]
    },
    "browser_action": {
        "default_title": "native messaging"
    },
    "permissions": [
        "nativeMessaging"
    ],
    "manifest_version": 2
}

本地应用:

//**manifest.json**
{
    "name": "terminal",
    "description": "Open Your Terminal",
    "path": "E:\\workspace\\open_terminal\\terminal.bat",
    "type": "stdio",
    "allowed_origins": {
        "chrome-extension://imefmccdbejlchmiempjpojbflghofdo/"
    }
}
//**terminal.bat**
@echo off

cd %systemRoot%\system32
start cmd.exe

我的问题是,我的代码是否有错误?或者是chrome版本或者操作系统的问题?我的chrome是25.0.1364.172 m,操作系统是window 7。或者告诉我在bat中怎么调试?至少能查看是否执行了bat文件。多谢!


好像说版本要在29以上

【热门文章】
【热门文章】