John Stern
John Stern

Reputation: 11

How can I mimic CTRL+A, CTRL+C in WebBrowser Control through COM or JavaScript?

How can I mimic CTRL+A, CTRL+V in WebBrowser Control automatically via COM?

Alternatively, is there a way of simulating this behaviour using JavaScript?

I looked all over and it seems that the only way to put data into the clipboard is to use the setData() method of the clipboardData object, but I end up with HTML being interpreted as text. What I need is to put an entire webpage into the clipboard so it can be pasted into MS Word.

Upvotes: 1

Views: 1061

Answers (1)

Pops
Pops

Reputation: 30848

This answer was discovered by the OP and posted as an update to the question. Just moving it here for semantics.

Here's the solution in JavaScript (can be used through COM as well):

window.document.execCommand('SelectAll',true);
window.document.execCommand('Copy',true);
window.document.execCommand('UnSelect',true);

Upvotes: 1

Related Questions