Home All Groups Group Topic Archive Search About

VB.net app to run in the background

Author
10 Oct 2006 5:08 PM
Link
hello i have made a program that record to file mouse moves .
but to record it its use :
Mouse_Move
sub and thats works just my form is visible
i want thats record even if my form is "me.hide()"
can i do that ?

Author
10 Oct 2006 6:57 PM
GhostInAK
Hello Link,

If I remember correctly the Win32 API is called GetCursorPosition().

-Boo

Show quoteHide quote
> hello i have made a program that record to file mouse moves .
> but to record it its use :
> Mouse_Move
> sub and thats works just my form is visible
> i want thats record even if my form is "me.hide()"
> can i do that ?
Author
11 Oct 2006 5:47 PM
teslar91
I'm guessing you'll want to record mouse clicks too.  Since your form
doesn't have focus, it doesn't receive mouse events; therefore you have
to poll the "key state" of the mouse buttons repeatedly and rapidly,
else you'll miss clicks:

Const VK_LBUTTON = &H1 ' left-mousebutton
Const VK_RBUTTON = &H2 ' right-mousebutton
Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As
Int32) As Int32

Function MyGetKeystate(ByVal WhichKey As Int32) As Boolean
  ' Returns the status of a key.
  ' Pass one of the VK_* constants defined above, or any key value.
  If GetAsyncKeyState(WhichKey) And &H8000 Then MyGetKeystate = True
End Function

Function LeftButton() As Boolean
  LeftButton = MyGetKeystate(VK_LBUTTON)
End Function

Function Get RightButton() As Boolean
  RightButton = MyGetKeystate(VK_RBUTTON)
End Function

It should also be possible to hook into the Windows mouse handlers and
avoid polling, but that's beyond me.