|
-
Jun 27th, 2010, 08:06 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Make the mouse click
How do i make the mouse click by typing like Mouse.click.do if you get what i mean.
BEcause i need it to go to a position onscreen and click.
Also how would i do rightclick?
-
Jun 27th, 2010, 10:55 AM
#2
Thread Starter
Fanatic Member
-
Jun 27th, 2010, 12:06 PM
#3
Re: Make the mouse click
you can use the mouse_event api to simulate left or right mouseclicks:
vb Code:
Public Class Form1
Private Declare Sub SetCursorPos Lib "User32" (ByVal X As Integer, ByVal Y As Integer)
Private Const MOUSEEVENTF_LEFTDOWN As Integer = &H2
Private Const MOUSEEVENTF_LEFTUP As Integer = &H4
Private Const MOUSEEVENTF_RIGHTDOWN As Integer = &H6
Private Const MOUSEEVENTF_RIGHTUP As Integer = &H8
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, _
ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("you clicked")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim p As Point = Button1.PointToScreen(New Point(1, 1))
SetCursorPos(p.X, p.Y)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 27th, 2010, 01:06 PM
#4
Thread Starter
Fanatic Member
Re: Make the mouse click
thankyou,
-
Jun 27th, 2010, 02:51 PM
#5
Thread Starter
Fanatic Member
Re: [RESOLVED] Make the mouse click
in the end i used this code
VB.NET Code:
Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As IntPtr) Const MOUSEEVENTF_LEFTDOWN As Integer = 2 Const MOUSEEVENTF_LEFTUP As Integer = 4 Const MOUSEEVENTF_RIGHTDOWN As Integer = 6 Const MOUSEEVENTF_RIGHTUP As Integer = 8 mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
-
Jun 27th, 2010, 03:01 PM
#6
Re: [RESOLVED] Make the mouse click
 Originally Posted by Emcrank
in the end i used this code
VB.NET Code:
Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As IntPtr)
Const MOUSEEVENTF_LEFTDOWN As Integer = 2
Const MOUSEEVENTF_LEFTUP As Integer = 4
Const MOUSEEVENTF_RIGHTDOWN As Integer = 6
Const MOUSEEVENTF_RIGHTUP As Integer = 8
mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
that's not the way to do it. it could cause problems with your OS if you don't use it correctly, i.e. a MOUSEEVENTF_LEFTUP after a MOUSEEVENTF_LEFTDOWN + not combined
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 27th, 2010, 06:10 PM
#7
Thread Starter
Fanatic Member
Re: [RESOLVED] Make the mouse click
What do you mean?
EDIT: Oh do you mean i need to do????
Code:
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
Instead of both in the same mouse_event
Code:
mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)
Correct me if im wrong
-
Jun 27th, 2010, 06:32 PM
#8
Re: [RESOLVED] Make the mouse click
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 28th, 2010, 12:25 PM
#9
Thread Starter
Fanatic Member
Re: [RESOLVED] Make the mouse click
Why cant you use the + sign and have it in one?
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
|