Question message to another program

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
how can i send a message to a different program to press a button on it without me doing it with my mouse?
 
You would need to use the Windows API for that. You would need to call the FindWindow, FindWindowEx and SendMessage functions. This is a common request so a search will find existing examples. It's the BM_CLICK message that you'll want to send.
 
would this send a click to the window at 678,512 of the window?

VB.NET:
       Const WM_LBUTTONDOWN As Long = &H201
       Const WM_LBUTTONUP As Long = &H202

       SetForegroundWindow(hwnd)

       SendMessage(hwnd, WM_LBUTTONDOWN, 0&, MakeDWord(678, 512))
       SendMessage(hwnd, WM_LBUTTONUP, 0&, MakeDWord(678, 512))


    Private Function MakeDWord(ByVal LoWord As Integer, ByVal HiWord As Integer) As Long
        MakeDWord = (HiWord * &H10000) Or (LoWord And &HFFFF&)
    End Function

the window come to foreground and then nothing happen.
 
Last edited:
Back
Top