SendKeys {ENTER} to Webbrowser ( Note: SendKeys must send the key ONLY TO the Webbrowser ) Not outside of my application

Hello experts,

I have been working with a project around 1 month and i cannot find the solution to SendKeys {Enter} to the webbrowser , i have try SendKeys {Enter} , but it will send the key where your mouse are focus, I want to send key {ENTER} Only to my webbrowser, please find me a solution

I use vb6.0

Who is Participating?
Please elaborate more a bit - from where do you want send key - your application?
In this case:
SendKeys "~"

From other application (of from within your's but without changin focus)?
In this case:
    PostMessage(wbHWND, WM_KEYDOWN, VK_RETURN, ByVal 0&)
    PostMessage(wbHWND, WM_KEYUP, VK_RETURN, ByVal 0&)
where wbHWND is a handle to your WebBrowser control

What do you mean saying "WebBrowser"? Separate Internet Explorer window? All IE windows? Another browsers as well (NN, Opera etc)? Or webbrowser control inside your application?
You should identify the object in the DOM of your browser's current document and use the .Submit method.


Much better that sending an {enter} key somewhere...

KingSencatAuthor Commented:
First COmment:Webbrowser control inside my application,,

Second Comment:There is a special reason that i need it to do it with the Enter Button , someones know the way ?
Beg to differ, but I doubt that. The enter key on a page can have only three effects: insert a new line in a multi-line text box (like the one I'm typing in right now), following a hyperling, or activating the Submit of a button.

Perhaps you are going to say that you want to launch some special code hooking the keyboard, but even that can be launched without using Sendkeys. A web page is a totally open object, in terms of contents and automation.

But if you don't know enough about DOM and web pages, you can try the classical tricks of Sendkeys.
1) play with the Wait parameter (second argument to Sendkeys)
2) try to issue the Sendkeys *before* activating your browser

Good luck!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.