CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Global detection of mouseclick

    How to detect if mouse had been clicked anywhere on the screen, not only form....

    Thank You


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Global detection of mouseclick

    check out this article on vbaccelerator
    http://vbaccelerator.com/codelib/hook/vbalhook.htm
    it tells you everything about hooks and how to use the in vb


  3. #3
    Join Date
    May 1999
    Posts
    3,332

    Re: Global detection of mouseclick

    on second thought...
    you could also use GetAsyncKeyState API to find out if a certain mouse button has been pressed.


  4. #4
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Re: Global detection of mouseclick

    hmm, this is not exactly what I needed I meant global as if the mouse was pressed anywhere on the screen not on the form or control only, even if I doubleclick "My Computer" and form is minimized it still detects mouse click, about GetAsyncKeyState I'll see if I can figure out how to make it work, because I had never used it before, anyway thank you from replying


  5. #5
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: Global detection of mouseclick

    Here's how you can use the GetAsyncKeyState API:
    private Declare Function GetAsyncKeyState Lib "user32" (byval vKey as Long) as Integer
    private Const VK_LBUTTON = &H1
    private Const VK_RBUTTON = &H2

    private Sub Form_Load()
    Timer1.Interval = 100
    End Sub

    private Sub Timer1_Timer()
    If GetAsyncKeyState(VK_LBUTTON) then
    Caption = "Left Click"
    ElseIf GetAsyncKeyState(VK_RBUTTON) then
    Caption = "Right Click"
    else
    Caption = ""
    End If
    End Sub



    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

  6. #6
    Guest

    Re: Global detection of mouseclick

    Thanks a lot for helping )


    []'s


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

Featured