Results 1 to 5 of 5

Thread: hold mouse button down

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    47

    hold mouse button down

    soz for not being more efficent with the search function

    but im trying to figure out how to hold the left mose botton down for a period of time and all i can manage to do it make it press then sleep , then press etc.

    could some1 send me some useful code or a working example pllzzz

    ty

    edit: btw i wish to hold the right mouse button down not the left ^^ ty

    Code:
    For i = 0 To 30
     mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&, cButt, dwEI
     Sleep 200
    Next i

  2. #2

    Re: hold mouse button down

    This should do the trick
    Code:
    For i = 0 To 30
        mouse_event MOUSEEVENTF_RIGHTDOWN, 0&, 0&, cButt, dwEI
        Sleep 200
        mouse_event MOUSEEVENTF_RIGHTUP, 0&, 0&, cButt, dwEI
    Next i

  3. #3
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: hold mouse button down

    Sleep will not hold it down for a period of time i think.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: hold mouse button down

    No it wont but if you manually click down the button and enable a timer control in the button_mousedown event, it can fire your repetitive task/function in the tick event and then disable the timer in the mouseup event it should give the effect you want.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Re: hold mouse button down

    You can make it easier on him, instead of using a timer. You can try the DoEvents, and it should work.

    Code:
    For i = 0 To 30
        mouse_event MOUSEEVENTF_RIGHTDOWN, 0&, 0&, cButt, dwEI
        DoEvents
        Sleep 200
        mouse_event MOUSEEVENTF_RIGHTUP, 0&, 0&, cButt, dwEI
        DoEvents
    Next i

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