Re: Point me in the right direction - Mouse utility...



Could you help me implement this source code in VB.Net or give me the sample
source code from VB6 so I can try...?

I appreciate it this would really help...

Thanks,
Jonathan
titanicsa2@xxxxxxxxxx

"DanS" wrote:

> "Noozer" <dont.spam@xxxxxxx> wrote in
> news:AcY1f.111295$1i.18146@pd7tw2no:
>
> > I've been looking for a simple utility to take advantage of my
> > scrolling third button but have not been able to find what I'm looking
> > for. I'm considering writing my own using VB6...
> >
> > What I simply want to do is:
> > - Capture any middle click events
> > - When a click occurs, display a list of items that the user can
> > scroll through
> > - Left-clicking on an item will "type" that entry into the currently
> > selected point in the current application.
> > - Middle-clicking the list will just close it.
> > - Right-clicking the list will pop up a context menu to access
> > settings, exit the app, etc.
> > - I want to do this throughout Windows, not within a single or
> > specific application. It would be nice if I could detect the currently
> > active application and/or the application where the mouse was clicked
> > over so I could present a list of items relative to that application.
> >
> > ... so, where would I start with this? It should be a piece of cake to
> > write, once I figure out how to capture the mouse events from anywhere
> > in Windows.
> >
> > Alternatively, does anyone know of an existing utility that can do
> > this?
> >
> > Thanks!
> >
> >
>
> ok , here's a point, WH_MOUSE_LL, is a low-level mouse hook that is
> system wide in standard VB WITHOUT and C-based DLL.
>
> the code below is good for a system-wide keyboard and/or mouse hook.
>
> call StartMouseHook to start, stopMouseHook when exiting your program.
>
> throw this code in its own module for easy reuse....
>
>
> regards,
>
> DanS
>
>
> Code Begin
> -----------------------------------------------------------------
> Option Explicit
>
> Public Const WH_KEYBOARD_LL = 13
> Private Const WH_MOUSE_LL As Long = 14
>
> Private Const HC_ACTION As Integer = 0
>
> Private Const WM_MOUSEMOVE As Integer = &H200
> Private Const WM_LBUTTONDOWN As Integer = &H201
> Private Const WM_LBUTTONUP As Integer = &H202
> Private Const WM_LBUTTONDBLCLK As Integer = &H203
> Private Const WM_RBUTTONDOWN As Integer = &H204
> Private Const WM_RBUTTONUP As Integer = &H205
> Private Const WM_RBUTTONDBLCLK As Integer = &H206
> Private Const WM_MBUTTONDOWN As Integer = &H207
> Private Const WM_MBUTTONUP As Integer = &H208
> Private Const WM_MBUTTONDBLCLK As Integer = &H209
> Private Const WM_MOUSEWHEEL As Integer = &H20A
>
>
>
> Private Type KBDLLHOOKSTRUCT
> vkCode As Long ' virtual key code
> scanCode As Long ' scan code
> flags As Long ' flags
> time As Long ' time stamp for this message
> dwExtraInfo As Long ' extra info from the driver or keybd_event
> End Type
>
> Private Type Point
> x As Long
> y As Long
> End Type
>
> Private Type MSLLHOOKSTRUCT
> pt As Point
> mouseData As Integer
> flags As Integer
> time As Integer
> dwExtraInfo As Integer
> End Type
>
> Public Declare Function SetWindowsHookEx Lib "user32" Alias
> "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod
> As Long, ByVal dwThreadId As Long) As Long
> Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As
> Long) As Long
>
> Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As
> Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
> Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
> (pDest As Any, pSrc As Any, ByVal ByteLen As Long)
>
> Private kb_struct As KBDLLHOOKSTRUCT
> Private mouse_struct As MSLLHOOKSTRUCT
>
> Global kbd_Hook As Long
> Global mouse_Hook As Long
>
> Public Function startKeyboardHook() As Boolean
>
> kbd_Hook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KeyboardProc,
> App.hInstance, ByVal 0&)
> If kbd_Hook <> 0 Then
> startKeyboardHook = True
> End If
>
> End Function
>
> Public Sub stopKeyboardHook()
> UnhookWindowsHookEx kbd_Hook
> End Sub
> Public Function KeyboardProc(ByVal nCode As Long, ByVal wParam As Long,
> ByVal lParam As Long) As Long
> If nCode = HC_ACTION Then
> CopyMemory kb_struct, ByVal lParam, LenB(kb_struct)
> Debug.Print kb_struct.scanCode
> End If
> KeyboardProc = CallNextHookEx(kbd_Hook, nCode, wParam, lParam)
> End Function
>
> Public Function startMouseHook() As Boolean
> mouse_Hook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf MouseProc,
> App.hInstance, ByVal 0&)
> If mouse_Hook <> 0 Then
> startMouseHook = True
> End If
> End Function
>
> Public Sub stopMouseHook()
> UnhookWindowsHookEx mouse_Hook
> End Sub
>
> Public Function MouseProc(ByVal nCode As Long, ByVal wParam As Long,
> ByVal lParam As Long) As Long
> If nCode = HC_ACTION Then
> CopyMemory mouse_struct, ByVal lParam, LenB(mouse_struct)
> Select Case wParam
> Case WM_MOUSEMOVE
>
> Case WM_LBUTTONDOWN
>
> Case WM_LBUTTONUP
>
> Case WM_LBUTTONDBLCLK
>
> Case WM_RBUTTONDOWN
>
> Case WM_RBUTTONUP
>
> Case WM_RBUTTONDBLCLK
>
> Case WM_MBUTTONDOWN
>
> Case WM_MBUTTONUP
>
> Case WM_MBUTTONDBLCLK
>
> Case WM_MOUSEWHEEL
> End Select
> End If
> MouseProc = CallNextHookEx(mouse_Hook, nCode, wParam, lParam)
> End Function
> ---------------------------------------------------------------
> Code End
>
.


Loading