选择&用 C 或 C++ 将 Firefox 内容复制到剪贴板
我发现了一些与我类似的问题,但没有一个答案令人满意,而且它们已经有几年了。所以我希望自那时以来在这方面可能取得了一些进展。
我感兴趣的是能够使用 C 或 C++ 代码访问活动 Firefox 窗口的内容并将其复制到剪贴板。
在 Internet Explorer 中,我可以使用 COM 的 IHTMLDocument2 访问浏览器的内容
Firefox 中有类似的东西吗?如果是这样,我该怎么做?
顺便说一句,我当前(丑陋的)解决方法是通过发送虚拟击键来模仿 Ctrl+A、Ctrl+C,但这不是一个真正强大且优雅的解决方案。
想法、技巧、见解、知识将不胜感激。
谢谢。
注意:为了进一步澄清这一挑战,我想指出,我对 基于Javascript或Flash 基于解决方案。相反,我对 C/C++ 解决方案感兴趣,即使它仅限于 Microsoft Windows 平台。
I found a few questions similar to mine but none of the answers are satisfactory and they are a few years old. So I am hoping that perhaps some progress has been made on that front since then.
What I am interested in is the ability to access the content of an active Firefox window and copy it to the clipboard -- using C or C++ code.
In Internet Explorer I can use COM's IHTMLDocument2 to access the broswer's contents DOM.
Is there something similar in Firefox? If so, how do I do that?
BTW, my current (ugly) workaround is to mimic Ctrl+A, Ctrl+C by sending virtual keystrokes, but this is not a truly robust and elegant solution.
Ideas, tips, insight, knowledge would be greatly appreciated.
Thanks.
Note: To further clarify the challenge, I would like to note that I am not interested in a Javascript based or Flash based solution. Instead, I am interested in a C/C++ solution, even if it is limited to the Microsoft Windows platform only.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
firefox 中的 DOM 通过 XPCOM 暴露给 C++,但要注意,与 MSHTML(在 IE 中)不同,它的接口Mozilla 中的接口并不总是冻结,未冻结接口是特定于版本的,并且可能会因版本而异。
IHTMLDocument2
的 XPCOM 等效项是nsIDOMDocument
。XPCOM 与 COM 非常相似,基类称为 nsISupports ,并且具有与 IUnknown 完全相同的语义(包括相同的二进制布局和 GUID) )但不要假设所有内容都从 COM 映射到 XPCOM(例如 XPCOM 中没有
IDispatch
)。The DOM in firefox is exposed to C++ via XPCOM but beware, unlike MSHTML (in IE) the interfaces in Mozilla are not always frozen the unfrozen interfaces are version specific and may change from release to release.
The XPCOM equivalent of
IHTMLDocument2
isnsIDOMDocument
.XPCOM is very similar to COM, the base class is called
nsISupports
and has exactly the same semantics asIUnknown
(including the same binary layout andGUID
) but don't assume that everything maps from COM to XPCOM (for example there is noIDispatch
in XPCOM).