2022-07-06, 12:59:05
Hi,
I'm not aware of any specific functionality for this exposed by WebView2.
In your case I would be looking into trying to do this from javascript.
This link is a starting point for that: https://developer.mozilla.org/en-US/docs..._clipboard
So add the event-listener via ExecuteScript with code like:
and then add the event listener like:
I just tested that in MS Edge developer toolbox and it did indeed display the console log message.
FWIW, I'm using the html "body" selector here, but if you have something more specific then that should work as well.
Instead of writing to the console log you could then send a webmessage (see the webmessage demo in VB6 that comes with AntView) to trigger an event.
Based on that event triggering you can then read the clipboard from your application.
--
Wil
I'm not aware of any specific functionality for this exposed by WebView2.
In your case I would be looking into trying to do this from javascript.
This link is a starting point for that: https://developer.mozilla.org/en-US/docs..._clipboard
So add the event-listener via ExecuteScript with code like:
Code:
function myOnCopyEvent() {
console.log("Someone used Ctrl+C");
}
Code:
document.querySelector("body").addEventListener("copy", myOnCopyEvent);
I just tested that in MS Edge developer toolbox and it did indeed display the console log message.
FWIW, I'm using the html "body" selector here, but if you have something more specific then that should work as well.
Instead of writing to the console log you could then send a webmessage (see the webmessage demo in VB6 that comes with AntView) to trigger an event.
Based on that event triggering you can then read the clipboard from your application.
--
Wil