Click on External App Button VB2010

How to click on an external app button 🙂 Just working on something and needed to save this code lol
Delare

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Const WM_COMMAND As Integer = &H111S
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWndParent As IntPtr, ByVal hWndChildAfter As Integer, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
Private Const BM_CLICK = &HF5

Call it with

x = FindWindow("#32770", vbNullString)
button = FindWindowEx(x, 0&, "button", vbNullString)
button = FindWindowEx(x, button, "button", vbNullString)
SendMessage(button, BM_CLICK, 1, 0)

4 thoughts on “Click on External App Button VB2010

  1. What external app window exactly?

    Serching the button by it’s control id would probably be better  and send the main window WM_COMMAND instead the BM_CLICK to the button.

    Are you on Windows 7 or XP? I think there may be some hidden #32770 class windows

  2. I using Windows 8.1 I’m finally install VB 2010 hehehe So I can program in my Newer PC. I was trying to click on the Settings on Paltalk on the Banner tab, this the pic
    Slice 1
    I was thinking about activating the button then clicking it to take off the banner 🙂 Kindna crazy Idea I had in my mind 😆

  3. Well boith are controls with unique ID so easy to find with the same methid we use to find room controls.

    Make sure you get the right controls by checking their text.

    Then you can try to enable them and do whatever.

     

Leave a Reply

You must Register or Login to comment on Click on External App Button VB2010