Valhalla Legends Forums Archive | Visual Basic Programming | Send Mouse

AuthorMessageTime
Imperceptus
Does anyone know how to send mouse coordinates and events to another window?
March 30, 2004, 9:47 PM
Eli_1
[quote author=Imperceptus link=board=31;threadid=6075;start=0#msg52706 date=1080683248]
Does anyone know how to send mouse coordinates. . .[/quote]
Yes:
[code]
Declare Function SetCursorPosition Lib "user32" _
(ByVal x as long, ByVal y as long) as Long
[/code]


[quote author=Imperceptus link=board=31;threadid=6075;start=0#msg52706 date=1080683248]
. . . and events
[/quote]
Yes:
[code]
'//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
[/code]

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

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

Gives entry point error on user32.dll

Using SetCursorPos instead.
April 1, 2004, 5:22 AM
Eli_1
[quote author=Imperceptus link=board=31;threadid=6075;start=0#msg53008 date=1080796952]
Extra note, I think your example is for .Net... that or you were just poking me in the right direction.
[/quote]
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.
April 1, 2004, 11:40 AM

Search