Re: [2005] Sending Keys to other application Save
Update...but not a happy one.
I'm getting what LOOKS like the final button I need...but the MouseToSend doesn't seem to be sending the mouse click like it should. It keeps centering the mouse cursor over the top left of my main window and clicking there.
Re: [2005] Sending Keys to other application Save
Okay you don't need to use a Do Loop for the FindWindow.
This should do the exact same thing.
Code:
hWndApp = FindWindow(vbNullString, windText2)
Yes then use FindwindowEx in a do loop as I showed you.
Code:
Dim cwnd, ccwnd As Int32
Do
'Loop through all child windows on the main form
cwnd = FindWindowEx(hWndApp , cwnd, vbNullString, vbNullString)
If cwnd = 0 Then Exit Do 'if there are no more windows
'Search each grand child window(if any) for the checkbox button
ccwnd = FindWindowEx(cwnd, 0, "Button", "&Selected Objects Only")
If ccwnd <> 0 then Exit Do 'Exit if we find it!!
Loop
Messagebox.Show(ccwnd.ToString)'here is the handle!!
I dont think you have the handle of the grand child window yet, since it's clicking on the main window.
The above example should give you the exact handle, based upon your Spy+ list.
I recommend trying the SendMessage or PostMessage API first, to send the space key to the checkbox. Here is how my class would do it internally:
Code:
SendMessage(ccwnd, WM_KEYDOWN, VK_SPACE, Nothing)
SendMessage(ccwnd, WM_KEYUP, VK_SPACE, Nothing)
or
Code:
PostMessage(ccwnd, WM_KEYDOWN, VK_SPACE, Nothing)
PostMessage(ccwnd, WM_KEYUP, VK_SPACE, Nothing)
You'd need these constants to do it:
Code:
Const WM_KEYDOWN As Int32 = 256
Const WM_KEYUP As Int32 = 257
Const VK_SPACE As Int32 = 32
Re: [2005] Sending Keys to other application Save
Oh, thank god it's working. T_T I'm able to get it to click now. So it was just a matter of sending the space key to the handle. I could have sworn I had gotten the handle yesterday...but then again, I was hitting my head against this problem for a good 6 hours yesterday.
Thanks a lot for all the help...this program is still from being completed, but at least you got me over the hardest part. ^.^ Thanks!
Re: [RESOLVED] [2005] Sending Keys to other application Save
I'm glad to have helped.:wave: