0

Hey all im a little confused as the effect of this BM_CLICK issue.

Here is my code:

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, <MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) As Integer

Dim hwndParent As Long = FindWindow(vbNullString, "Video Source")
  Debug.Print("findwindow: " & hwndParent)
Dim hwndButton As Long = FindWindowEx(hwndParent, IntPtr.Zero, "Button", "OK")
  Debug.Print("OK: " & hwndButton)
hwndButton = SendMessage(hwndButton, BM_CLICK, 0, 0)
  Debug.Print("Clicked: " & hwndButton)

The debug output is:

findwindow: 856318
        OK: 1052904
   Clicked: 0

Now i have no idea why it doesnt find nor click on the OK button.

The Spy++ for that button looks like this:

enter image description here

Any help would be great!

StealthRT
  • 10,108
  • 40
  • 183
  • 342
  • Fix your API declarations (hint: `Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr`) and make sure there is only one button with caption "OK" and class "Button". – GSerg Jul 14 '13 at 22:19
  • @GSerg doesnt seem to help any. – StealthRT Jul 14 '13 at 22:31
  • Well, `FindWindow` and `FindWindowEx` find something, so they work. Make sure all declarations are correct, and there is only one window in the system that matches the criteria, because values found are different from values Spy++ shows. Also observe [requirements for BM_CLICK](http://msdn.microsoft.com/en-us/library/windows/desktop/bb775985.aspx) that may require the window to be active before you can send the message. – GSerg Jul 15 '13 at 07:37

0 Answers0