我正在制作某种简单的机器人,
但是问题是它对我完全不起作用,单击模拟不允许我在google,instagram ... textbox中输入文本,它只是单击元素作为按钮,然后按Enter键盘模拟中的按键不起作用,也是因为它不允许我进行Google搜索。
我已经使用了另一个stackflow帖子中的先前代码:C# CefSharp Offscreen mouse events, keyboard events emulating example
KeyEvent k = new KeyEvent
{
WindowsKeyCode = 13, // Enter
FocusOnEditableField = true,
IsSystemKey = false,
Type = KeyEventType.KeyDown
};
chromeBrowser.GetBrowser().GetHost().SendKeyEvent(k);
Thread.Sleep(RandomNumber(20,120));
k = new KeyEvent
{
WindowsKeyCode = 13, // Enter
FocusOnEditableField = true,
IsSystemKey = false,
Type = KeyEventType.KeyUp
};
chromeBrowser.GetBrowser().GetHost().SendKeyEvent(k);
chromeBrowser.GetBrowser().GetHost().SendMouseClickEvent(x, y, MouseButtonType.Left, false, 1, CefEventFlags.LeftMouseButton);
Thread.Sleep(120);
chromeBrowser.GetBrowser().GetHost().SendMouseClickEvent(x, y, MouseButtonType.Left, true, 1, CefEventFlags.LeftMouseButton);
我希望能够使用C#在Cefsharp中进行所有的键盘和鼠标单击模拟,而无需使用javascript