将 Enter 键发送到 Web 浏览器1
你好。
我尝试过;
PostMessage(embeddedwb1.Handle,VK_RETURN,0,0);
sendmessage(embeddedwb1,wm_keyup,vk_return,0);
embeddedwb1.perform(wm_keyup,vk_return,0);
但我的程序不起作用。 我尝试过;
Keybd_Event(VK_RETURN, 1, 0, 0);
我的程序可以运行。但这是用于发送所有应用程序的回车键的代码。我只想为我的程序编写代码。感谢您帮助我。
Hello.
I tried with ;
PostMessage(embeddedwb1.Handle,VK_RETURN,0,0);
sendmessage(embeddedwb1,wm_keyup,vk_return,0);
embeddedwb1.perform(wm_keyup,vk_return,0);
but my program doesn't work.
and i tried with ;
Keybd_Event(VK_RETURN, 1, 0, 0);
my program is worked.but that is code for sending enter key for All Applications.i want to code for just my program.Thank you for helping me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在调用
Keypd_Event(...)
之前,确保使用SetFocus(embeddedwb1.Handele)
聚焦 Web 浏览器。既然您可能想要提交表单,您是否考虑过使用 DOM 来实现这一点?下面是一些填充所选输入字段然后提交第一个表单的代码。如果您导航到 http://www.google.com,这种方法就很好用,但在现实世界中,您' d 需要更加小心(按类或 id 搜索输入字段,检查是否有表单等)
Make sure the WebBrowser is focused using
SetFocus(embeddedwb1.Handele)
before callingKeypd_Event(...)
.Since you probably want to submit a form, did you consider doing that with the DOM? Here's some code that fills in the selected input field and then submits the first form. This works just fine if you navigate to http://www.google.com, but in the real world you'd need to be a lot more careful (search the input field by class or id, check if there's a form, etc)
如果 Javascript 用于提交表单,那么我认为 Cosmin 答案不起作用。在这种情况下,您必须了解按钮的 JS 代码并从您的程序中执行它。例如;在我的页面中,我使用 JQuery 提交表单。所以:
if Javascript is used for submit form then Cosmin answer doesn't work I think. In this case you must know JS code of the button and execute it from your program. For example; in my page, I use JQuery to submit form. So:
使用此代码:
此代码将字符 13(输入代码)发送到 EmbeddedWB。
Use this:
This code send char 13 (Enter code) to EmbeddedWB.