elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Invertir Ejes del Raton
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Invertir Ejes del Raton  (Leído 4,859 veces)
Elemental Code


Desconectado Desconectado

Mensajes: 622


Im beyond the system


Ver Perfil
Invertir Ejes del Raton
« en: 19 Octubre 2010, 18:56 pm »

Hola.
Estoy tratando de hacer algo que invierta los ejes del raton.
osea que si voy a la derecha la flechita valla a la izquierda y etc.

Tengo el codigo Choreado Prestado del NRC de Psyke con hook al mouse pero ni idea como hacer

 puedo tomar la poscicion actual del cursor y hacerlo saltar a una.

osea, los comandos los tengo, me falta cabeza de programador.

Gracias por la ayuda.

Codigo del hook al mouse
Código
  1. Option Explicit
  2.  
  3. Private Declare Function SetWindowsHookEx Lib "user32.dll" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
  4. Private Declare Function UnhookWindowsHookEx Lib "user32.dll" (ByVal hHook As Long) As Long
  5.  
  6. Dim hHook As Long
  7.  
  8. Public Sub StartHook()
  9.    hHook = SetWindowsHookEx(14, AddressOf MouseProc, App.hInstance, 0)
  10. End Sub
  11.  
  12. Public Sub StopHook()
  13.    Call UnhookWindowsHookEx(hHook)
  14. End Sub
  15.  
  16. Private Function MouseProc(ByVal nCode As Long, ByVal wParam As Long, lParam As Long) As Long
  17.    'On Error Resume Next
  18.    If wParam = 516 Then 'si sirve de algo el wParam cuando se mueve el mouse es 512
  19.      Form1.Print "CLICK BOTON DERECHO"
  20.    ElseIf wParam = 517 Then Form1.Print "SOLTÓ BOTON DERECHO"
  21.    ElseIf wParam = 513 Then Form1.Print "CLICK BOTON IZQUIERDO"
  22.    ElseIf wParam = 514 Then Form1.Print "SOLTÓ BOTON IZQUIERDO"
  23.    ElseIf wParam = 519 Then Form1.Print "CLICK BOTON MEDIO"
  24.    ElseIf wParam = 520 Then Form1.Print "SOLTÓ BOTON MEDIO"
  25.    End If
  26.  
  27.    Form1.Caption = wParam
  28. End Function

Este es el codigo de pruebas que tengo en el form.
Código
  1. Option Explicit
  2. Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long
  3. Private Declare Function SetCursorPos Lib "User32" (ByVal X As Long, ByVal Y As Long) As Long
  4.  
  5. '\\Variables
  6. Private Type POINTAPI
  7.    X As Long
  8.    Y As Long
  9. End Type
  10.  
  11. Dim pt As POINTAPI
  12. Dim Que As Variant
  13. Dim cX As Integer, cY As Integer
  14. Private Sub Command1_Click()
  15.   GetCursorPos pt
  16.   cX = pt.X: cY = pt.Y
  17.   Command1.Caption = cX & ";" & cY
  18. End Sub
  19.  
  20. Private Sub Form_Load()
  21.  Me.AutoRedraw = True
  22.  StartHook
  23. End Sub
  24. Private Sub Form_Unload(Cancel As Integer)
  25.  StopHook
  26. End Sub

Cuando apretas el boton Command1 cambia su caption a las coordenadas del cursor
Para hacer "saltar" el cursor es
Código
  1. SetCursorPos [X,Y]


En línea

I CODE FOR $$$
Programo por $$$
Hago tareas, trabajos para la facultad, lo que sea en VB6.0

Mis programas
BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: Invertir Ejes del Raton
« Respuesta #1 en: 19 Octubre 2010, 19:03 pm »

.
Si no me equivoco debes modificar la estructurea lParam (En este hook, en este parametro de ddevuelve una estructura), despues de hacer eso pasa el mensaje normalmente!¡.

Dulce Infierno Lunar!¡.


En línea

The Dark Shadow is my passion.
Elemental Code


Desconectado Desconectado

Mensajes: 622


Im beyond the system


Ver Perfil
Re: Invertir Ejes del Raton
« Respuesta #2 en: 19 Octubre 2010, 19:23 pm »

El lParam tiene las coordenadas de X del cursor.

pero sigo sin entender
no se como hacer

Funsionaria si hago que cuando se mueva el mouse cursor valla a la diferencia entre el lPram actual y el antiguo menos el ancho total de la pantalla?
En línea

I CODE FOR $$$
Programo por $$$
Hago tareas, trabajos para la facultad, lo que sea en VB6.0

Mis programas
Psyke1
Wiki

Desconectado Desconectado

Mensajes: 1.089



Ver Perfil WWW
Re: Invertir Ejes del Raton
« Respuesta #3 en: 19 Octubre 2010, 19:32 pm »

Mira esto :

Código
  1.  
  2. Option Explicit
  3. Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
  4. Private Declare Function SetWindowsHookEx Lib "user32.dll" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
  5. Private Type POINTAPI
  6.    x As Long
  7.    y As Long
  8. End Type
  9. Private Type MOUSEHOOKSTRUCT
  10.    pt As POINTAPI
  11.    hwnd As Long
  12.    wHitTestCode As Long
  13.    dwExtraInfo As Long
  14. End Type
  15. Private Const WH_MOUSE As Long = 7
  16. Private Const WM_MOUSEMOVE As Long = &H200
  17. Private Declare Function CallNextHookEx Lib "user32.dll" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  18. Private Declare Function UnhookWindowsHookEx Lib "user32.dll" (ByVal hHook As Long) As Long
  19. Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
  20. Private Declare Function SetCursorPos Lib "user32.dll" (ByVal x As Long, ByVal y As Long) As Long
  21.  
  22. Private m_MousePt As POINTAPI
  23. Private m_HookProc As Long
  24. Private m_Ignore As Boolean
  25.  
  26. Public Sub HookMouse()
  27.    If m_HookProc = 0& Then
  28.        m_Ignore = True
  29.        m_HookProc = SetWindowsHookEx(WH_MOUSE, AddressOf MouseProc, App.hInstance, App.ThreadID)
  30.    End If
  31. End Sub
  32. Public Sub UnhookMouse()
  33.    If m_HookProc Then
  34.        UnhookWindowsHookEx m_HookProc
  35.        m_HookProc = 0&
  36.    End If
  37. End Sub
  38.  
  39. Private Function MouseProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  40.  
  41.    Dim mhs As MOUSEHOOKSTRUCT, tPt As POINTAPI
  42.    If wParam = WM_MOUSEMOVE Then
  43.        If nCode > -1& Then
  44.            CopyMemory mhs, ByVal lParam, Len(mhs)
  45.            If m_Ignore Then
  46.                m_MousePt = mhs.pt
  47.                m_Ignore = False
  48.            Else
  49.                tPt.x = mhs.pt.x - m_MousePt.x
  50.                tPt.y = mhs.pt.y - m_MousePt.y
  51.                If (tPt.x Or tPt.y) Then
  52.                    tPt.x = m_MousePt.x - tPt.x
  53.                    tPt.y = m_MousePt.y - tPt.y
  54.                    m_Ignore = True
  55.                    SetCursorPos tPt.x, tPt.y
  56.                    MouseProc = 1&
  57.                    Exit Function
  58.                End If
  59.            End If
  60.        End If
  61.    End If
  62.    MouseProc = CallNextHookEx(m_HookProc, nCode, wParam, lParam)
  63. End Function
Fuente

DoEvents! :P
En línea

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: Invertir Ejes del Raton
« Respuesta #4 en: 19 Octubre 2010, 19:58 pm »

...
,,,mmm Algo asi mas o menos desia yo xP...

Creo que anda un poco mal no lo probe, asi que alrato lo checo bien, aun asi lo dejo.

Código
  1.  
  2. Private Function MouseProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  3.    Dim mhs As MOUSEHOOKSTRUCT, tPt As POINTAPI
  4.    If wParam = WM_MOUSEMOVE Then
  5.        CopyMemory mhs, ByVal lParam, LenB(mhs)
  6.        tPt.x = mhs.pt.x - m_MousePt.x
  7.        tPt.y = mhs.pt.y - m_MousePt.y
  8.        If (tPt.x Or tPt.y) Then
  9.            tPt.x = m_MousePt.x - tPt.x
  10.            tPt.y = m_MousePt.y - tPt.y
  11.            m_Ignore = True
  12.        End If
  13.        lParam = VarPtr(mhs)
  14.        mhs
  15.    End If
  16.    MouseProc = CallNextHookEx(m_HookProc, nCode, wParam, lParam)
  17. End Function
  18.  
  19.  

Dulce Infienro Lunar!¡.
En línea

The Dark Shadow is my passion.
BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: Invertir Ejes del Raton
« Respuesta #5 en: 20 Octubre 2010, 09:36 am »

.
Aqui esta:

http://foro.elhacker.net/programacion_visual_basic/source_invertir_ejes_del_mouse-t308335.0.html

Dulce Infierno Lunar!¡.
En línea

The Dark Shadow is my passion.
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Comportamiento de <ul> ... invertir Lugar
Desarrollo Web
Hadess_inf 2 1,978 Último mensaje 2 Febrero 2013, 10:31 am
por Puntoinfinito
Ayuda ordenar ejes
Programación C/C++
majojimu 3 2,068 Último mensaje 4 Julio 2013, 09:37 am
por eferion
Robots y la gobernanza de la red, ejes del Día de Internet 2014
Noticias
wolfbcn 0 1,186 Último mensaje 8 Mayo 2014, 01:23 am
por wolfbcn
invertir una frase en C
Programación C/C++
lucho666 2 7,287 Último mensaje 17 Octubre 2014, 18:00 pm
por lucho666
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines