Getting mouse position, Moving mouse, Clicking once, and returning mouse to original position

Getting mouse position, Moving mouse, Clicking once, and returning mouse to original position

Post by MatthewBro » Mon, 13 Feb 2006 12:55:15


I'm interested in getting the mouse position, moving the mouse to (5,5)
then left clicking once, then sending a key, then moving the mouse back
to the original mouse position.



Sounds pretty crazy, and would make no sense; except I need to send
keyboard commands to a window that is located at 5,5.

Appactivate doesn't work as it's a Flash movie embedded in a WebBrowser
control; and although sending the keys to the WebBrowser control (after
setfocus) works, it will not send the keys to the Flash movie in the
WebBrowser control.

This is the only alternative that I could think of.


Thanks,

Matt
 
 
 

Getting mouse position, Moving mouse, Clicking once, and returning mouse to original position

Post by MatthewBro » Mon, 13 Feb 2006 17:19:41

getting mouse position:
http://www.yqcomputer.com/

 
 
 


Getting mouse position, Moving mouse, Clicking once, and returning mouse to original position

Post by MatthewBro » Mon, 13 Feb 2006 17:32:30

clicking the mouse:
http://www.yqcomputer.com/

mouse_event can also move the mouse
 
 
 

Getting mouse position, Moving mouse, Clicking once, and returning mouse to original position

Post by MatthewBro » Mon, 13 Feb 2006 17:41:48

Or... all three in one:
http://www.yqcomputer.com/


Module as follows (watch wrap)


Option Explicit

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 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
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
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 Sub