Is there a mouse click script already that I've missed?
I just thought I'd ask before reinventing the wheel...
I just thought I'd ask before reinventing the wheel...
If this is your first visit, be sure to check out the FAQ. You must register before you can post.
IMPORTANT: Your first post will be checked for appropriate content. This may take a bit of time.
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Sub Main(ByVal Sval as String)
Windows.Forms.Cursor.Current.Position = New System.Drawing.Point(225, 105)
hs.waitsecs(2)
Call mouse_event(&H2, 0, 0, 0, 1)
hs.waitsecs(1)
Call mouse_event(&H4, 0, 0, 0, 1)
End Sub
#IMPORT System.Drawing,system.drawing.dll #IMPORT System.Windows.Forms,system.windows.forms.dll Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal dwData As Long, ByVal dwExtraInfo As IntPtr) Private Const MouseEventLeftDown As Int32 = 2 Private Const MouseEventLeftUp As Int32 = 4 Public Sub Main(ByVal param As Object) Dim params() As String = param.ToString().Split("|") If params.Length > 2 Then GenerateMouseClick(params(0), params(1), params(2)) End Sub Private Sub GenerateMouseClick(ByVal x As Integer, ByVal y As Integer, Optional ByVal mouseclicks As Integer = 2, Optional ByVal return_mouse As Boolean = True) Try If mouseclicks < 1 OrElse mouseclicks > 3 Then hs.WriteLog("MouseClick", "Only 1, 2 or 3 mouse clicks are allowed") Exit Sub End If Dim pointOldPosition As Point = Windows.Forms.Cursor.Position Windows.Forms.Cursor.Position = New Point(x, y) For i As Integer = 1 To mouseclicks mouse_event(MouseEventLeftDown, 0, 0, 0, New System.IntPtr()) mouse_event(MouseEventLeftUp, 0, 0, 0, New System.IntPtr()) Next If return_mouse Then Windows.Forms.Cursor.Position = pointOldPosition Catch ex As Exception hs.WriteLog("MouseClick", "Error occured. Sorry about that...") End Try End Sub
Comment