I am using USER32 to SetForegroundWindow to make it the active window and SendMessage to do a keydown of Enter. I am able to see that I have the handle on it, but the "ENTER" is not working!!! Any idea's???
Have you searched this site in your forums for SendMessage? Last 30 days? You would have found this thread713-744609 that I belive will help you in your quest.
Thank you, this is what I am looking for. I am able to get the handle of the window. The defaulted button on the form is "OK", so I want to hit enter so that it follows the defaulted procedure. But it returns a zero. Any idea why this isn't working???
You need to get the handle of the child window. Specifically the handle to the command button you want to click. So you will need to use something like the EnumChildWindows API.
Use all 4 SendMessages as I show in the above posted thread. But, I think that you need to use the EnumChildWindows instead of the GetWindow API because of the following from the remarks section about GetWindow...
[tt]
The EnumChildWindows function is more reliable than calling GetWindow in a loop. An application that calls GetWindow to perform this task risks being caught in an infinite loop or referencing a handle to a window that has been destroyed.
[/tt]
And then to make sure that you have the correct window you should check its caption(text) with something like GetWindowText
Okay, I am able to get the handle of a button and do:
Dim str1 As String
str1 = "hello"
iret = SendMessage(hwnd, WM_SETTEXT, 0, ByVal str1)
and it changes the text of the button. But whenever I try to do a sendmessage of clicking a button, nothing works.. do you know what the correct command is for having it click that button?
click on this > Thread713-744609 and goto the last entry of mine where I use 4 different sendmessages to click a button and try them in that order with those constants and values.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.