Welcome Guest Search | Active Topics | Sign In | Register

Send mouse/keyboard events Options
ozheek
Posted: Monday, December 5, 2016 7:59:15 AM
Rank: Advanced Member
Groups: Member

Joined: 8/29/2016
Posts: 64
Hello,

Before sending mouse/keyboard events do we need to set focus to WebView that will receive this event?

Or it's multi thread safe and we don't need to worry about switching between WebViews?
eo_support
Posted: Monday, December 5, 2016 8:35:13 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

You can use these methods to send events to the WebView:

https://www.essentialobjects.com/doc/eo.webbrowser.webview.sendchar_overloads.aspx
https://www.essentialobjects.com/doc/eo.webbrowser.webview.sendkeyevent_overloads.aspx
https://www.essentialobjects.com/doc/eo.webbrowser.webview.sendmouseevent.aspx

These methods themselves do not care about focus. However the script in the page may check where the focus is when they receive keyboard/mouse event. For those you may need to set focus first. However there is no reliable way to ensure a WebView is properly focused since setting focus is asynchronously on the WebView. So usually it's not a good idea to send keyboard/mouse events to the page in order to automate the page. You should use non interactive approach instead --- for example, instead of trying to "click" a button to submit the form, you can call the form's submit method directly. The former is interactive, the later is not.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.