Frederick
2008-04-21 12:19:17
This module of course comes in great use when your wanting to move your mouse to positions on your screen, Also at the bottom will be examples of how i've used it.
So, The Module Itself:
Some examples of use:
//This shows the basics of using the module, The Rnd is a random ammount this trys to stop it being so suspicous - but still be verry careful
but also:
//This will show the current mouse X and Y Cordinates into a label called lblCurrent.
–
Hope this helps.
– Fred
So, The Module Itself:
Option Explicit
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Long) As Integer
Public 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)
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal Y As Long) As Long
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
Public Const MOUSEEVENTF_MIDDLEUP = &H40
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10
Public Const MOUSEEVENTF_MOVE = &H1
Public Type POINTAPI
x As Long
Y As Long
End Type
Public Random As Integer
Public Log As Integer
Public Function GetCurrentX() As Long
Dim Position As POINTAPI
GetCursorPos Position
GetCurrentX = Position.x
End Function
Public Function GetCurrentY() As Long
Dim Position As POINTAPI
GetCursorPos Position
GetCurrentY = Position.Y
End Function
Public Sub LeftClick()
LeftDown
Sleep(Random)
LeftUp
End Sub
Public Sub LeftDown()
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
End Sub
Public Sub LeftUp()
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Public Sub MiddleClick()
MiddleDown
MiddleUp
End Sub
Public Sub MiddleDown()
mouse_event MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0
End Sub
Public Sub MiddleUp()
mouse_event MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0
End Sub
Public Sub MoveMouse(xMove As Long, yMove As Long)
mouse_event MOUSEEVENTF_MOVE, xMove, yMove, 0, 0
End Sub
Public Sub RightClick()
RightDown
Sleep(Random)
RightUp
End Sub
Public Sub RightDown()
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
End Sub
Public Sub RightUp()
mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
End SubSome examples of use:
Public Sub Drop()
'FIRST ROW
'First item
Call SetCursorPos(Int(Rnd * 2 + 835), Int(Rnd * 2 + 395))
Call Sleep(Random)
Call RightClick
Call Sleep(Random)
Call SetCursorPos(Int(Rnd * 2 + 821), Int(Rnd * 2 + 435))
Call Sleep(Random)
Call LeftClick
Call Sleep(Random)
end sub
//This shows the basics of using the module, The Rnd is a random ammount this trys to stop it being so suspicous - but still be verry careful
but also:
lblCurrent.Caption = "X Cordinates: " & GetCurrentX & " Y Cordinates: " & GetCurrentY
//This will show the current mouse X and Y Cordinates into a label called lblCurrent.
–
Hope this helps.
– Fred