I'm a big fan of automation, so whenever I'm given the chance I like to try and automate tasks that I have to repeat. The following code usually allows me to click the mouse wherever it is on the screen (and in whatever application that may be):
Public Declare Auto Function SetCursorPos Lib "User32.dll" (ByVal X As Integer, ByVal Y As Integer) As Long
Public Declare Auto Function GetCursorPos Lib "User32.dll" (ByRef lpPoint As Point) As Long
Public 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)
Public Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Public Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20 ' middle button down
Public Const MOUSEEVENTF_MIDDLEUP = &H40 ' middle button up
Public Const MOUSEEVENTF_RIGHTDOWN = &H8 ' right button down
Public Const MOUSEEVENTF_RIGHTUP = &H10 ' right button up
This usually works no problem. I've used it in a range of applications to great effect. However I'm now trying to do some mouse clicking (and key stroke sending) to an application that just seems to completely ignore the mouse and keyboard commands. Once the mouse has move into the area of the screen covered by the program it doesn't move, click etc, but it I move the mouse away manually it continue with the process as if it had been working correctly.
So is there any other way to control the mouse programmatically, that would simulate the mouse in a way that is indistinguishable from me moving it about by hand?