Visual Basic - Ayuda Con Mouse En VB

Life is soft - evento anual de software empresarial
 
Vista:

Ayuda Con Mouse En VB

Publicado por Jorge (4 intervenciones) el 24/01/2007 06:38:50
Bueno necesito una pequeña ayuda, estuve buscando sobre movimientos del mouse en este foro i pude encontrar esto ...

*****

Private Type POINTAPI
x As Long
y As Long
End Type

Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
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 MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up

Sub MoverMouse(x As Single, y As Single)
Dim pt As POINTAPI

pt.x = x
pt.y = y

SetCursorPos x, y

mouse_event MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

Private Sub Command1_Click()
MoverMouse 30, 10
End Sub

Nota: Yo en lugar de un command le puse un timer asi se hacia automaticamente ...

*****

Pero lo que necesito es que primero haga click en una cordenada establecida ( como puede ser 30 10 ) i luego en dnd se encontraba el mouse inicialmente ...

Es posible hacer eso?, tambien es posible aumentar la velocidad en la que se produce el clikeo ...

Desde ya muchas gracias ...
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ayuda Con Mouse En VB

Publicado por Jasall (27 intervenciones) el 24/01/2007 09:32:41
Buenas, tienes que añadir la api GetCursorPos y un timer para poder captar la posicion del cursor en la pantalla, te quedaria de esta manera.

'

Private Type POINTAPI
X As Long
Y As Long
End Type
Dim Posicion As POINTAPI

Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
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 Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up

Sub MoverMouse(X As Single, Y As Single)
Dim pt As POINTAPI

pt.X = X
pt.Y = Y

SetCursorPos X, Y

mouse_event MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

Private Sub Command1_Click()
MoverMouse 30, 10
SetCursorPos LX, LY
End Sub

Private Sub Timer1_Timer()
GetCursorPos Posicion
LY = Posicion.Y
LX = Posicion.X
End Sub

' saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ayuda Con Mouse En VB

Publicado por Jorge (4 intervenciones) el 24/01/2007 14:00:42
Que interval le pongo al timer? ... xq no se que pasa que a ves cuando pongo intervalos muy chicos es como que titila el bloq num, de todos modos usare todos timer para que los clickeos sean automaticos ...

Muchas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar