Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select & Copy firefox content to clipboard in C or C++

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.

like image 513
Android Eve Avatar asked Dec 16 '25 22:12

Android Eve


1 Answers

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 is nsIDOMDocument.

XPCOM is very similar to COM, the base class is called nsISupports and has exactly the same semantics as IUnknown (including the same binary layout and GUID) but don't assume that everything maps from COM to XPCOM (for example there is no IDispatch in XPCOM).

like image 198
Motti Avatar answered Dec 19 '25 14:12

Motti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!