|
-
Feb 25th, 2013, 03:42 AM
#1
Thread Starter
Lively Member
mouse button
Hi,
How can I send a click with my mouse in vb.net 2010?
the old way in vb6 isnt working
Code:
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 mouseclickup = 4
Private Const mouseclickdown = 2
Code:
' mouse_event(mouseclickdown, 0, 0, 0, 0)
' mouse_event(mouseclickup, 0, 0, 0, 0)
who can help me out?
-
Feb 25th, 2013, 05:25 AM
#2
Junior Member
Re: mouse button
If you have a form application, this should work:
Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
AddHandler Me.MouseClick, AddressOf Me.HandleMouse
End Sub
Private Sub HandleMouse(sender As Object, e As MouseEventArgs)
End Sub
-
Feb 25th, 2013, 09:38 AM
#3
Thread Starter
Lively Member
Re: mouse button
 Originally Posted by CrazyVB
If you have a form application, this should work:
Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
AddHandler Me.MouseClick, AddressOf Me.HandleMouse
End Sub
Private Sub HandleMouse(sender As Object, e As MouseEventArgs)
End Sub
no sorry i mean something like the sendkeys function in vb.net, but isntead its sending keys it should send a mouse click left or right.
how do you do something like that?
-
Feb 25th, 2013, 10:06 AM
#4
Junior Member
Re: mouse button
Is this what you mean?
Code:
Dim x As Integer = 1 'x position of the click
Dim y As Integer = 1 'y position of the click
Dim button As Windows.Forms.MouseButtons = Windows.Forms.MouseButtons.Left 'Button to be pressed
Dim delta As Integer = 0 'Scroll wheel movement
Dim ev As New MouseEventArgs(button, clicks, x, y, delta)
OnMouseClick(ev)
-
Feb 25th, 2013, 07:14 PM
#5
Re: mouse button
but isntead its sending keys it should send a mouse click left or right.
This doesn't really make any sense. A mouse click never exists in isolation from a position on the screen and what's there. Perhaps if you could be a bit more specific about what you want the click sent to (and why) it would help us to help you properly.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 26th, 2013, 12:15 AM
#6
Re: mouse button
It's probably not in isolation... generally there's a mouse move kind of command, to put the cursor at a specific spot... say... on a button for instance... followed by the click message... which would then click the button... sounds like possibly the OP has the mouse move messages down, and now needs to send the WM_LBUTTONDOWN message...
-tg
-
Feb 26th, 2013, 06:59 AM
#7
Re: mouse button
If the mouse_event function worked for you in VB6 it will work for you in VB.Net. Just change all the arguments from Long to Integer in the declaration. You also need to specify the type for your constants.
Code:
Private Const mouseclickup As Integer = 4
Last edited by Joacim Andersson; Feb 26th, 2013 at 07:02 AM.
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
|