mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 11:42:36 +00:00
Add sendkeyevent example to CefSharp.OffScreen.Example/Program.cs
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CefSharp;
|
||||
using CefSharp.Example;
|
||||
using CefSharp.Example.Handlers;
|
||||
using CefSharp.Internals;
|
||||
@@ -85,6 +86,17 @@ namespace CefSharp.OffScreen.Example
|
||||
// For Google.com pre-pupulate the search text box
|
||||
await browser.EvaluateScriptAsync("document.getElementById('lst-ib').value = 'CefSharp Was Here!'");
|
||||
|
||||
//Example using SendKeyEvent for input instead of javascript
|
||||
//var browserHost = browser.GetBrowserHost();
|
||||
//var inputString = "CefSharp Was Here!";
|
||||
//foreach(var c in inputString)
|
||||
//{
|
||||
// browserHost.SendKeyEvent(new KeyEvent { WindowsKeyCode = c, Type = KeyEventType.Char });
|
||||
//}
|
||||
|
||||
////Give the browser a little time to finish drawing our SendKeyEvent input
|
||||
//await Task.Delay(100);
|
||||
|
||||
// Wait for the screenshot to be taken,
|
||||
// if one exists ignore it, wait for a new one to make sure we have the most up to date
|
||||
await browser.ScreenshotAsync(true).ContinueWith(DisplayBitmap);
|
||||
|
||||
Reference in New Issue
Block a user