Autor
|
Tema: Invertir Ejes del Raton (Leído 5,063 veces)
|
Elemental Code
Desconectado
Mensajes: 622
Im beyond the system
|
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 Option Explicit 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 Private Declare Function UnhookWindowsHookEx Lib "user32.dll" (ByVal hHook As Long) As Long Dim hHook As Long Public Sub StartHook() hHook = SetWindowsHookEx(14, AddressOf MouseProc, App.hInstance, 0) End Sub Public Sub StopHook() Call UnhookWindowsHookEx(hHook) End Sub Private Function MouseProc(ByVal nCode As Long, ByVal wParam As Long, lParam As Long) As Long 'On Error Resume Next If wParam = 516 Then 'si sirve de algo el wParam cuando se mueve el mouse es 512 Form1.Print "CLICK BOTON DERECHO" ElseIf wParam = 517 Then Form1.Print "SOLTÓ BOTON DERECHO" ElseIf wParam = 513 Then Form1.Print "CLICK BOTON IZQUIERDO" ElseIf wParam = 514 Then Form1.Print "SOLTÓ BOTON IZQUIERDO" ElseIf wParam = 519 Then Form1.Print "CLICK BOTON MEDIO" ElseIf wParam = 520 Then Form1.Print "SOLTÓ BOTON MEDIO" End If Form1.Caption = wParam End Function
Este es el codigo de pruebas que tengo en el form. Option Explicit Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long Private Declare Function SetCursorPos Lib "User32" (ByVal X As Long, ByVal Y As Long) As Long '\\Variables Private Type POINTAPI X As Long Y As Long End Type Dim pt As POINTAPI Dim Que As Variant Dim cX As Integer, cY As Integer Private Sub Command1_Click() GetCursorPos pt cX = pt.X: cY = pt.Y Command1.Caption = cX & ";" & cY End Sub Private Sub Form_Load() Me.AutoRedraw = True StartHook End Sub Private Sub Form_Unload(Cancel As Integer) StopHook End Sub
Cuando apretas el boton Command1 cambia su caption a las coordenadas del cursor Para hacer "saltar" el cursor es 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
Mensajes: 3.158
I'Love...!¡.
|
. 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
Mensajes: 622
Im beyond the system
|
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
Mensajes: 1.089
|
Mira esto : Option Explicit Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long 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 Private Type POINTAPI x As Long y As Long End Type Private Type MOUSEHOOKSTRUCT pt As POINTAPI hwnd As Long wHitTestCode As Long dwExtraInfo As Long End Type Private Const WH_MOUSE As Long = 7 Private Const WM_MOUSEMOVE As Long = &H200 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 Private Declare Function UnhookWindowsHookEx Lib "user32.dll" (ByVal hHook As Long) As Long Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long) Private Declare Function SetCursorPos Lib "user32.dll" (ByVal x As Long, ByVal y As Long) As Long Private m_MousePt As POINTAPI Private m_HookProc As Long Private m_Ignore As Boolean Public Sub HookMouse() If m_HookProc = 0& Then m_Ignore = True m_HookProc = SetWindowsHookEx(WH_MOUSE, AddressOf MouseProc, App.hInstance, App.ThreadID) End If End Sub Public Sub UnhookMouse() If m_HookProc Then UnhookWindowsHookEx m_HookProc m_HookProc = 0& End If End Sub Private Function MouseProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim mhs As MOUSEHOOKSTRUCT, tPt As POINTAPI If wParam = WM_MOUSEMOVE Then If nCode > -1& Then CopyMemory mhs, ByVal lParam, Len(mhs) If m_Ignore Then m_MousePt = mhs.pt m_Ignore = False Else tPt.x = mhs.pt.x - m_MousePt.x tPt.y = mhs.pt.y - m_MousePt.y If (tPt.x Or tPt.y) Then tPt.x = m_MousePt.x - tPt.x tPt.y = m_MousePt.y - tPt.y m_Ignore = True SetCursorPos tPt.x, tPt.y MouseProc = 1& Exit Function End If End If End If End If MouseProc = CallNextHookEx(m_HookProc, nCode, wParam, lParam) End Function
FuenteDoEvents!
|
|
|
En línea
|
|
|
|
BlackZeroX
Wiki
Desconectado
Mensajes: 3.158
I'Love...!¡.
|
... ,,,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. Private Function MouseProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim mhs As MOUSEHOOKSTRUCT, tPt As POINTAPI If wParam = WM_MOUSEMOVE Then CopyMemory mhs, ByVal lParam, LenB(mhs) tPt.x = mhs.pt.x - m_MousePt.x tPt.y = mhs.pt.y - m_MousePt.y If (tPt.x Or tPt.y) Then tPt.x = m_MousePt.x - tPt.x tPt.y = m_MousePt.y - tPt.y m_Ignore = True End If lParam = VarPtr(mhs) mhs End If MouseProc = CallNextHookEx(m_HookProc, nCode, wParam, lParam) End Function
Dulce Infienro Lunar!¡.
|
|
|
En línea
|
The Dark Shadow is my passion.
|
|
|
BlackZeroX
Wiki
Desconectado
Mensajes: 3.158
I'Love...!¡.
|
|
|
|
En línea
|
The Dark Shadow is my passion.
|
|
|
|
|