如何使用扩展程序以编程方式触发 Chrome 中的快捷键? (NPAPI 或 JavaScript 扩展)
试图找出如何通过我自己的扩展执行“Ctrl + Shift + i”来自动触发 Web 开发人员工具。有一个 stackoverflow 问题,但没有一个答案有效。
Trying to figure out how to automatically trigger the web developer tools by executing the "Ctrl + Shift + i" via my own extension. There is one stackoverflow question, but none of the answers worked.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这真是太棒了,但不幸的是,用 javascript 是不可能的。
It would be awesome, but unfortunately it is not possible with javascript.
NPAPI 插件不会做你想做的事; NPAPI 插件不处理浏览器本身的任何内容,只处理它们所在的网页。它们也不能自动加载。
对于 NPAPI 插件,你能做的最好的事情就是将其放入 Chrome 扩展中,并将其用作其他内容的一部分;如果 Chrome 扩展本身不允许您捕获这样的热键,则可以使用 C++ 代码和某种挂钩来捕获热键并将其作为 传递给浏览器,但这将是一个非常特定于系统的系统完全不受支持的黑客攻击,您必须为您想要支持的每个操作系统找出解决方案;没有用于此类事情的 NPAPI 浏览器 API。
An NPAPI plugin will not do what you want; NPAPI plugins don't deal with anything that is of the browser itself, only with the webpage they are placed in. They also can't be automatically loaded.
The best you could do with a NPAPI plugin would be to put it in a Chrome Extension and use it as part of something else; if Chrome Extensions don't natively allow you to capture hotkeys like that it might be possible to use C++ code and some sort of hook to catch the hotkey and pass it on to the browser as a , but it would be a very system specific and completely unsupported hack that you'd have to figure out for each OS that you want to support; there are no NPAPI browser APIs for this sort of thing.