Results 1 to 4 of 4

Thread: How do you make the mouse click/dbl-click outside of a VB form?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    Atlanta, GA
    Posts
    177

    Talking

    How do you make the mouse click/dbl-click outside of a VB form, like on the desktop? In otherwords how can I make the mouse click on desktop icons and/or start menu applications?
    212 will lead you to the truth

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Use the keyboard_event API Function.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715

  4. #4
    Guest
    Try the following
    Code:
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Type POINTAPI
        x As Long
        y As Long
    End Type
    Private Const MK_LBUTTON = &H1
    Private Const WM_LBUTTONDBLCLK = &H203
    
    
    Private Sub Command1_Click()
        Dim PT As POINTAPI
        Dim Wnd As Long
        
        'Set the cursor position
        SetCursorPos (Me.Top / 32) + 100, (Me.Left / 32) + 100
        'Retrieve the cursor position
        GetCursorPos PT
        'Get the hWnd the mouse is over
        Wnd = WindowFromPoint(PT.x, PT.y)
        'Send a message to double click it
        PostMessage Wnd, WM_LBUTTONDBLCLK, MK_LBUTTON, 0
    End Sub
    
    Private Sub Form_DblClick()
        MsgBox "You double clicked the Form"
    End Sub

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