SuperPeng

Hi, I am writing a BHO ing C# and I need to paste some text into the current cursor position of a textarea.

Basically, I am trying to do the same thing as Right-Click->Paste, instead of paste from the clipboard, I am pasting from a variable inside my BHO.

I am able to get the textarea element when a certain event is triggered, but I don't know where the cursor is.

Anybody has any experience on this

Thanks!




Re: Internet Explorer Extension Development [BHO] [C#] How do I paste text into the current position of a textarea?

IECUSTOMIZER

Hi,

You could copy your variable to the clipboard and then use the webbrowser Execwb method to paste it into the document, but this may fail if the security settings prevent clipboard access.

Try adding a reference in your bho to mshtml.dll and create a region object (this will be the insertion point where the carrot is positioned or the current text selection) and then set the innerText property of the region with your variable's contents. You should be able to test if the region is within a tag of a certain type or class (Textarea).

Regards.