Foros del Web » Programación para mayores de 30 ;) » .NET »

funciones del API sendmessage

Estas en el tema de funciones del API sendmessage en el foro de .NET en Foros del Web. bien amigos.. resulta que estoy haciendo una pequeña aplicacion y no se por que falla lcualquier funcion con sendmessage , en cambio el mouse_event si ...
  #1 (permalink)  
Antiguo 21/10/2008, 16:21
 
Fecha de Ingreso: octubre-2008
Mensajes: 1
Antigüedad: 15 años, 6 meses
Puntos: 0
funciones del API sendmessage

bien amigos.. resulta que estoy haciendo una pequeña aplicacion y no se por que falla lcualquier funcion con sendmessage , en cambio el mouse_event si funciona
bien se trata de poner el iexplorer en una pagina de internet... te pones con el raton encima de una palabra luego nuestro proyecto mediante un timer se activa
y genera tres clics de raton mediante mouse_event obligando a seleccionar la palabra del explorer despues quiero copiar la seleccion al portapapeles mediante
sendmessage pero no me funciona , mando el codigo haber que me reportais

estoy desesperado he buscado el wm_copy por todo el google y no he conseguido que rule no da error pèro no copya nada.

a se me olvidaba es con vb2008.

gracias



Public Class Form1
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const MOUSEEVENTF_MOVE As Integer = &H1 ' mouse move
Private Const MOUSEEVENTF_LEFTDOWN As Integer = &H2 ' left button down
Private Const MOUSEEVENTF_LEFTUP As Integer = &H4 ' left button up
Private Const MOUSEEVENTF_RIGHTDOWN As Integer = &H8 ' right button down
Private Const MOUSEEVENTF_RIGHTUP As Integer = &H10 ' right button up
Private Const MOUSEEVENTF_MIDDLEDOWN As Integer = &H20 ' middle button down
Private Const MOUSEEVENTF_MIDDLEUP As Integer = &H40 ' middle button up
Private Const MOUSEEVENTF_WHEEL As Integer = &H800 ' wheel button rolled
Private Const MOUSEEVENTF_ABSOLUTE As Integer = &H8000 ' absolute move
Private Const WM_COPY As Integer = &H301
Private Const WM_PASTE = &H302
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer) As Integer
Private Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Integer, ByVal y As Integer) As Integer
Private Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As Point) As Integer
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As System.IntPtr) As Integer
'<System.Runtime.InteropServices.DllImport("user32 .DLL")> _
Private Shared Function SendMessage( _
ByVal hWnd As System.IntPtr, ByVal wMsg As Integer, _
ByVal wParam As Integer, ByRef lParam As Integer _
) As IntPtr
End Function
<System.Runtime.InteropServices.DllImport("user32. dll")> _
Private Shared Function FindWindow( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As System.IntPtr
End Function

Private Declare Function GetForegroundWindow Lib "User32" () As Integer
Dim P(0 To 6) As Point
Dim Index As Integer
Dim Jump1 As Boolean
Dim Hnd As IntPtr







Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Clipboard.Clear()
Dim j As IntPtr
j = GetForegroundWindow() ' captura el hwnd correcto ya que tengo el iexplorer activo y el mouse encima
Dim l As Integer
Dim cur As Point
cur = Cursor.Position
mouse_event(MOUSEEVENTF_LEFTUP Or MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) ' esto ba ok
mouse_event(MOUSEEVENTF_LEFTUP Or MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) 'esto ba ok
mouse_event(MOUSEEVENTF_LEFTUP Or MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) ' esto ba ok
System.Threading.Thread.Sleep(50)' intento darle tiempo pero tampoco ba la proxima linea
l = SendMessage(j, WM_COPY, 0, 0) '................................................. .....................' Esto es lo que falla y el hwnd esta bien en la j

MsgBox(Clipboard.GetText) ' deberia presentar el texto copiado pero no lo hace, presenta la ventana vacia

End Sub
End Class
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:27.