Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Imperceptus on March 30, 2004, 03:47 PM

Title: Send Mouse
Post by: Imperceptus on March 30, 2004, 03:47 PM
Does anyone know how to send mouse coordinates and events to another window?
Title: Re:Send Mouse
Post by: Eli_1 on March 30, 2004, 07:40 PM
Quote from: Imperceptus on March 30, 2004, 03:47 PM
Does anyone know how to send mouse coordinates. . .
Yes:

Declare Function SetCursorPosition Lib "user32" _
(ByVal x as long, ByVal y as long) as Long



Quote from: Imperceptus on March 30, 2004, 03:47 PM
. . . and events
Yes:

'//Here's the prototype, Imp
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)

'//Some constants it uses
Const EVENT_LEFTDOWN = &H2
Const EVENT_LEFTUP = &H4
Const EVENT_MIDDLEDOWN = &H20
Const EVENT_MIDDLEUP = &H40
Const EVENT_RIGHTDOWN = &H8
Const EVENT_RIGHTUP = &H10
Const EVENT_MOVE = &H1

'//Useage
'//Example shows you how to left click
mouse_event EVENT_LEFTDOWN, 0, 0, 0, 0
mouse_event EVENT_LEFTUP, 0, 0, 0, 0


[Edit 1      ] Added the second part of his question
[Edit 2 - 9] Re-arranged the text  :-\
Title: Re:Send Mouse
Post by: Imperceptus on March 31, 2004, 03:41 PM
awesome, thanks.
Title: Re:Send Mouse
Post by: Imperceptus on March 31, 2004, 11:22 PM
Extra note, I think your example is for .Net... that or you were just poking me in the right direction.

Declare Function SetCursorPosition Lib "user32" _
(ByVal x as long, ByVal y as long) as Long


Gives entry point error on user32.dll

Using SetCursorPos instead.
Title: Re:Send Mouse
Post by: Eli_1 on April 01, 2004, 05:40 AM
Quote from: Imperceptus on March 31, 2004, 11:22 PM
Extra note, I think your example is for .Net... that or you were just poking me in the right direction.
I figured setting the cursor position is easy enough to figure out, yet the mouse_event is a little harder, which is why I gave you code for that one.