Results 1 to 3 of 3

Thread: Detect mouse movement anywhere. [resolved]

  1. #1

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Lightbulb Detect mouse movement anywhere. [resolved]

    I'm looking for an API that reacts on mouse movement, even
    when the mouse is not on my form.
    It would be best if it could activate a sub whenever the mouse
    moves.

    Searching in MSDN I found mouse_event, which seemed the
    perfect solution, but the API has been superseded in Win 2000
    and up. Instead I should use SendInput. When I do a
    search, the most relevant page is this one, but I wouldn't
    have a clue on how to integrate this API into VB...


    Does anyone of you know the syntax of SendInput?
    - or -
    If this isn't the right API after all, what I should use?

    Thanks a lot,
    arsmakman.
    Last edited by arsmakman; Apr 29th, 2004 at 03:40 AM.
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Basically, you can make a timer, then make a call to retrieve the mouse coordinate.

    If you do a search you should be able to find a thread here with the APIs and types you need.

  3. #3

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Talking

    After doing a search I found the following code:
    VB Code:
    1. Private Type POINTAPI
    2.     X As Long
    3.     Y As Long
    4. End Type
    5. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    6. Dim curPos As POINTAPI
    7.  
    8. Private Sub Timer1_Timer()
    9.     GetCursorPos curPos
    10.     Text1 = "X:" + Str$(curPos.X) + " Y:" + Str$(curPos.Y)
    11. End Sub
    It works perfectly!
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width