[Ayuda] Simular un click del mause

Iniciado por Flamer, 9 Marzo 2015, 21:13 PM

0 Miembros y 1 Visitante están viendo este tema.

Flamer

Hola amigos estoy intentando simular un click con el mause, ya lo intente con un script pero no se puede ya que es muy limitado y ahora lo intento desde vb6 este es el codigo que tengo:
Código (vb) [Seleccionar]

Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
 

Private P_HANDLE As Long
Private P_PID As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
' constantes para SendMessage
Private Const WM_LBUTTONDBLCLK As Long = &H203 ' izquierdo doble click
Private Sub Command1_Click()
If FindWindow(vbNullString, "BlueStacks App Player for Windows (beta-1)") Then
  GetWindowThreadProcessId FindWindow(vbNullString, "BlueStacks App Player for Windows (beta-1)"), P_PID
  P_HANDLE = OpenProcess(PROCESS_ALL_ACCESS, False, P_PID)
End If
Timer1.Interval = 500
End Sub
Private Sub Form_Unload(Cancel As Integer)
CloseHandle P_HANDLE
End Sub

Private Sub Timer1_Timer()
   Call SendMessage(P_HANDLE, WM_LBUTTONDBLCLK, 1, ByVal 0&)
End Sub


saludos flamer y haber quien me hecha una mano

Miseryk

Cita de: Flamer en  9 Marzo 2015, 21:13 PM
Hola amigos estoy intentando simular un click con el mause, ya lo intente con un script pero no se puede ya que es muy limitado y ahora lo intento desde vb6 este es el codigo que tengo:
Código (vb) [Seleccionar]

Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
 

Private P_HANDLE As Long
Private P_PID As Long
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
' constantes para SendMessage
Private Const WM_LBUTTONDBLCLK As Long = &H203 ' izquierdo doble click
Private Sub Command1_Click()
If FindWindow(vbNullString, "BlueStacks App Player for Windows (beta-1)") Then
  GetWindowThreadProcessId FindWindow(vbNullString, "BlueStacks App Player for Windows (beta-1)"), P_PID
  P_HANDLE = OpenProcess(PROCESS_ALL_ACCESS, False, P_PID)
End If
Timer1.Interval = 500
End Sub
Private Sub Form_Unload(Cancel As Integer)
CloseHandle P_HANDLE
End Sub

Private Sub Timer1_Timer()
   Call SendMessage(P_HANDLE, WM_LBUTTONDBLCLK, 1, ByVal 0&)
End Sub


saludos flamer y haber quien me hecha una mano

Por ahora encontré como enviar MOUSEDOWN y MOUSEUP y funcionan, no logré el click común pero ésto sería casi lo mismo, y el doble click tendría que verlo.

Código (vb) [Seleccionar]

Option Explicit

Private Const WM_LBUTTONDOWN As Long = &H201
Private Const WM_LBUTTONUP As Long = &H202
Private Const MK_LBUTTON As Long = &H1&

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub SimClick(ByVal windowHwnd As Long, ByVal PosX As Integer, ByVal PosY As Integer)
SendMessage windowHwnd, WM_LBUTTONDOWN, MK_LBUTTON, MakeDWord(PosX, PosY)
SendMessage windowHwnd, WM_LBUTTONUP, 0, MakeDWord(PosX, PosY)
End Sub

Private Function MakeDWord(ByVal LoWord As Integer, ByVal HiWord As Integer) As Long
MakeDWord = (HiWord * &H10000) Or (LoWord And &HFFFF&)
End Function

Private Sub Command1_Click()
Dim hwnd As Long

hwnd = FindWindow(vbNullString, "CLICKME")

Call SimClick(hwnd, CInt(50), CInt(50))
End Sub
Can you see it?
The worst is over
The monsters in my head are scared of love
Fallen people listen up! It's never too late to change our luck
So, don't let them steal your light
Don't let them break your stride
There is light on the other side
And you'll see all the raindrops falling behind
Make it out tonight
it's a revolution

CL!!!

Miseryk

Acá tenés el doble click.

Código (vb) [Seleccionar]

Option Explicit
 
' función SendMessage
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
   ByVal hwnd As Long, _
   ByVal wMsg As Long, _
   ByVal wParam As Long, _
   ByVal lParam As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Const WM_LBUTTONDBLCLK As Long = &H203
 
Private Function MakeDWord(ByVal LoWord As Integer, ByVal HiWord As Integer) As Long
MakeDWord = (HiWord * &H10000) Or (LoWord And &HFFFF&)
End Function
 
Public Sub SimDobleClick(ByVal hwnd As Long, ByVal PosX As Integer, ByVal PosY As Integer)
Call SendMessage(hwnd, WM_LBUTTONDBLCLK, 0, MakeDWord(PosX, PosY))
End Sub
 
Private Sub Command1_Click()
Call SimDobleClick(FindWindow(vbNullString, "CLICKME"), 100, 100)
End Sub
Can you see it?
The worst is over
The monsters in my head are scared of love
Fallen people listen up! It's never too late to change our luck
So, don't let them steal your light
Don't let them break your stride
There is light on the other side
And you'll see all the raindrops falling behind
Make it out tonight
it's a revolution

CL!!!

Flamer

hola amigo ya lo solucione en el mismo dia...

Pero doy gracias  alos 2 por el apoyo

bueno saludos flamer y gracias