PDA

Click to See Complete Forum and Search --> : How do you make the mouse click/dbl-click outside of a VB form?


Doc Scheinder
Sep 28th, 2000, 01:40 PM
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?

Vlatko
Sep 30th, 2000, 06:55 AM
Use the keyboard_event API Function.

oetje
Sep 30th, 2000, 09:14 AM
http://vbapi.com/ref/m/mouse_event.html

Sep 30th, 2000, 11:56 AM
Try the following

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