CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Click action

  1. #1
    Join Date
    Jan 2000
    Location
    NY
    Posts
    12

    Click action

    I need to create a code that will simulate a mouse click, an actual mouse click.
    For example, I want the mouse to click every n seconds, and I want to do it where ever the mouse is, on a VB app or not. I’m emphasizing, an actual mouse click just as if some one is physically clicking the mouse button.

    Any one have any ideas?.
    If you can please email me your idea to [email protected]

    Thanks.

    Lee



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

    Re: Click action

    try 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 ' left button down
    private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up

    private Sub Form_Load()
    Timer1.Interval = 100
    End Sub

    private Sub Timer1_Timer()
    static sTimer as Single

    If sTimer = 0 then sTimer = Timer
    If (Timer - sTimer) > 5 then
    sTimer = Timer
    mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
    End If
    End Sub




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

  3. #3
    Join Date
    Jan 2000
    Location
    NY
    Posts
    12

    Re: Click action

    Thank you very much, this is just what I was looking for.
    Thanks.


  4. #4
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Re: Click action

    I know this might be stupid question but I just wanted to know.....why in the hell would you want your mouse to click every second? LOL


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