Re: Point me in the right direction - Mouse utility...
- From: "Someone" <nobody@xxxxxxx>
- Date: Sat, 8 Oct 2005 20:11:01 -0400
The only way I know of to capture mouse clicks that way is to use global
hooks and write a C++ DLL to handle the code that catches the click, and
then forward it to your form. There maybe an ActiveX out there if you can't
make a C++ DLL, but make sure that it support global hooks. While a hook
procedure can reside in an EXE, a global hook requires a DLL to work
correctly. If you use SetWindowsHookEx and point the hook procedure to your
EXE, the function will return success, but it will monitor only the threads
in your process(EXE).
API functions to check:
SetWindowsHookEx
GetCursorPos
WindowFromPoint
SetForegroundWindow
Messages:
WM_NCMBUTTONUP
WM_MBUTTONUP
To display your menu, you could use the following VB6 code. It's what others
are using to display a popup menu when someone clicks on a tray icon.
PopupMenu mnuFile, , x, y
> - Middle-clicking the list will just close it.
I don't know if this is supported by VB6. You may have to use subclassing or
the hook procedure.
> - Right-clicking the list will pop up a context menu to access settings,
> exit the app, etc.
It's better to use a try icon for this, or a menu item "More...", otherwise
you have to make more special coding.
> - will "type" that entry into the currently selected point in the current
> application.
Use Clipboard.SetText to paste the text. Note that 3rd party apps are not
uniform, you can't use WM_SETTEXT with some applications. WM_SETTEXT can be
used to set some simple controls in 3rd party apps, like Labels and
TextBoxes, but it doesn't work on grids for example, and some applications
hide the details of the controls inside them so you can't easily get the
hWnd for them, this includes EnumWindows and EnumChildWindows. IE for
instance hides the controls that it displays on web pages. For example, you
can't paste a text other than by using the clipboard or via IE Automation.
Finally, global hook DLL's don't unload immediately when you uninstall the
hook, sometimes the DLL stays in memory until you reboot. Also, any bugs in
the hook will crash any of your applications, including the IDE, so they are
not easy to develop. Keep the hook as simple as possible and use PostMessage
to send information to your form(which is subclassed). Don't use SendMessage
unless you are sure that your message will be processed quickly. SendMessage
doesn't return to the originating app until the recipient finishes
processing the message(reached End Sub/Function), including waiting for a
user to click on a MsgBox.
"Noozer" <dont.spam@xxxxxxx> wrote in message
news:AcY1f.111295$1i.18146@xxxxxxxxxxx
> 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!
>
.
- References:
- Point me in the right direction - Mouse utility...
- From: Noozer
- Point me in the right direction - Mouse utility...
- Prev by Date: Re: How should one form call another?
- Next by Date: Re: How should one form call another?
- Previous by thread: Point me in the right direction - Mouse utility...
- Next by thread: Re: Point me in the right direction - Mouse utility...
- Index(es):
Relevant Pages
|