Results 1 to 4 of 4

Thread: Detecting MouseUp on another apps form

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Vancouver,Canada
    Posts
    6

    Question Detecting MouseUp on another apps form

    Hi,

    I am trying to find out how I can detect the mouseup on a form that belongs to another application. I can detect the left key via GetAsyncKeyState but haven't come across any code to detect the mouseup.

    Any ideas?

    Thanks,

    Rob

  2. #2
    Megatron
    Guest
    You can only detect the "MouseDown's" with GetAsyncKeyState. If you want to detect a MouseUp, you'd have to subclass the App.

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You can detect a global MouseUp by Tracking the return value of the same GetAsyncKeyState() API function, i.e.
    Code:
    Option Explicit
    
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    
    Private Sub Form_Load()
        Timer1.Interval = 10
    End Sub
    
    Private Sub Timer1_Timer()
        Static bDown As Boolean
    
        If GetAsyncKeyState(vbLeftButton) < 0 Then
            ' Log that the Mouse was pressed.
            bDown = True
        Else
            ' When the mouse is no longer depressed and it was previously, a Mouse Up must have occured.
            If bDown Then Debug.Print "Mouse Up"
            bDown = False
        End If
    End Sub

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Actually, you can use a mouse hook instead, that means you don't need to use a timer to repeatedly check for the mouse button states. search on Setwindowhookex and you'll find out.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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