SendKey 进入浏览器控件 WinForm .Net
我需要使用 GeckoFX Web Control 在网页中发送 Enter 按键事件。
我无法使用 SendKeys.Send({ENTER})
有没有办法在网页中通过 Javascript 发送输入?
i need to send the Enter key press Event in a Web Page using GeckoFX Web Control.
I can't use SendKeys.Send({ENTER})
Is there a way to send enter via Javascript in a WebPage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您使用的是 geckofx,因此您可以使用 nsIDOMWindowUtils 接口来发送按键。
请注意,通常无法通过普通 JavaScript 使用 nsIDOMWindowUtils 接口,因为它需要 UniversalXPConnect 特权。
Since you are using geckofx you can use the nsIDOMWindowUtils interface to send the keypress.
Note one normally can't use the nsIDOMWindowUtils interface from normal javascript, as it requires the UniversalXPConnect privileged.
这是巫术魔法:
C# COM 版本,将 ENTER 按键分派到 GeckoWebBrowser 中的 GeckoNode。
不幸的是我还没有在 GeckoFX 18 中找到合适的包装器,所以所有工作都是通过 xpcom 完成的。
13 是 Enter 的代码,如果需要发送字符,请将其设置为 0 并将字符代码用作 InitKeyEvent 的最后一个参数
。这里 e 是您要向其发送按键的对象。
JavaScript 版本,如果您可以注入 javascript,这将在 javascript 环境中执行相同的操作
here is the voodoo magic:
C# COM version, dispatches ENTER keypress to GeckoNode in GeckoWebBrowser.
Unfortunately i havent found suitable wrapper in the GeckoFX 18, so all work is done via xpcom.
13 is the code for enter, if you need to send characters, set it to 0 and use the charcode as the last parameter to InitKeyEvent
Here e is the object youre dispatching key press to.
JavaScript version, if you can inject javascript this will do the same from within javascript environment