|
-
May 11th, 2007, 09:20 AM
#1
Thread Starter
Member
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
-
May 12th, 2007, 06:32 AM
#2
Member
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
-
May 12th, 2007, 09:49 PM
#3
Re: hold mouse button down
Sleep will not hold it down for a period of time i think.
-
May 12th, 2007, 11:58 PM
#4
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
May 14th, 2007, 08:19 AM
#5
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|