CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 1999
    Location
    Haddonfield, NJ (South Jersey)
    Posts
    84

    HOW TO: Simulate/force mouse click...

    Does anyone have any idea? Workaround, hints, etc...
    I tried using PostMessage() but that does not seem to work.

    --maciej



  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: HOW TO: Simulate/force mouse click...

    Use the Mouse_Event API, ie.

    private Declare Sub mouse_event Lib "user32" (byval dwFlags as Long, byval dx as Long, byval dy as Long, byval cButtons as Long, byval dwExtraInfo as Long)
    private Const MOUSEEVENTF_LEFTDOWN = &H2
    private Const MOUSEEVENTF_LEFTUP = &H4

    private Sub Command1_Click()
    Call mouse_event(MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
    End Sub





    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

  3. #3
    Guest

    Re: HOW TO: Simulate/force mouse click...

    First get the handle for the object you want to click. You can use functions like "findwindow", "getwindow"... ONce you get the window, use the API "sendmessage". Here is an example:

    call sendmessage(buttonhWnd%, WM_LBUTTONDOWN, 0&, 0&)
    call sendmessage(buttonhWnd%, WM_LBUTTONUP, 0&, 0&)



    that should click an object. hope it helped!

    -Will [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured