Ver Mensaje Individual
  #4 (permalink)  
Antiguo 23/04/2007, 11:08
boluart
 
Fecha de Ingreso: enero-2007
Ubicación: Tingo María - Perú
Mensajes: 399
Antigüedad: 18 años, 3 meses
Puntos: 13
Re: Click Automatico en VB

Código:
 
 
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Declare Function PostMessageBynum 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 GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
         Left As Long
         Top As Long
         Right As Long
         Bottom As Long
End Type
Private Sub Command1_Click()
    Me.Print "Usted hizo click el el Command 1"
End Sub
Private Sub Command2_Click()
    Me.Print "Usted hizo click el el Command 2"
    Dim l As Long, PosX As Long, PosY As Long, PosXY As Long
    Dim lpRect As RECT
    l = GetWindowRect(Command1.hwnd, lpRect)
    PosX = lpRect.Left + ((lpRect.Right - lpRect.Left) / 2)
    PosY = lpRect.Top + ((lpRect.Bottom - lpRect.Top) / 2)
    l = SetCursorPos(PosX, PosY)
    PosXY = (PosY - lpRect.Top) * 65536 + (PosX - lpRect.Left)
    l = PostMessageBynum(Command1.hwnd, WM_LBUTTONDOWN, 0&, PosXY)
    l = PostMessageBynum(Command1.hwnd, WM_LBUTTONUP, 0&, PosXY)
End Sub
__________________
Vivir para ser buenos y ser buenos para servir mejor.