Link to home
Start Free TrialLog in
Avatar of choonghooi
choonghooi

asked on

How to send click event to button on other application

Hi,

Anyone know how to send "click" to button on other application. I tried alot of example from internet but still no luck.

Below is a portion of my existing code:
Dim hwnd As Long
 hwnd = FindWindowEx(hwnd, 0, "Button", "Cancel") 'vbNullString)
        If hwnd = 0 Then
            MsgBox("Couldn't find the button")
            Exit Sub
        End If

'PostMessage(hwnd, BM_CLICK, 0, 0)

I do not know why its not working. Need help.

Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

If you are really using VB.Net then you need to change the data types as the code you have posted is for VB6 (or below).

To convert to VB.Net you need to change all "Long" to "Integer".  (You can use "IntPtr" for window handles instead.)

Don't forget to change any other API declarations and all of your local variables as well...

So it would look like:
Private Const BM_CLICK As Integer = &HF5
Private Declare Function SendMessage Lib "user32" (ByVal handle As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
 
...
    Dim hwnd As Integer
    ...
    SendMessage(hwnd, BM_CLICK, 0, 0)

Open in new window

Avatar of choonghooi
choonghooi

ASKER

Idle_Mind,

Thanks :)
I need to sendmessage to hide a toolbar inside pdf. By using spy++, i found out that the toolbar described as Window 00B51286 "AVToolBarEasel" AVL_AVView, i try the below codes:

hwnd_box = FindWindowEx(app_hwnd, 0, "AVL_AVView", "AVToolBarEasel")
PostMessage(hwnd_box, SW_HIDE, 0, 0)

However i coudnt get the handler for AVToolBarEasel, any idea? Please refer to the attached print screen, there are several entries of AVL_AVView and the highlighted is the correct one.


AVToolBarEasel.GIF
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks alot :)