The TWatch Component V1.10
I am very interested in any application
that uses this component (or any other application you wrote).
If so, mail me (not the program, just an
URL or similar) !
(mail address below)
Installation:
=============
1. Copy the files Watch.pas and watch.dcr to the directory where
you store your components (or let it where it is)
2. In Delphi, select Component|Install Component. In the
following dialog enter the path and filename of
Watch.pas and hit OK.
3. Now the TWatch Component is available in the
Component palette under Bome.
4. Load watchdll.dpr into Delphi and compile it. It creates
the
dll "watchdll.dll".
5. This library must be in the search path or in the directory of
the program in which you want to use TWatch. The
dll is loaded
and unloaded dynamically when needed, in order to prevent Delphi
to load it when installing the component.
Description
===========
This component enables you to track some system events.
Currently implemented are Shell events (i.e. Activation,
Creation, Closure of Applications), and Keyboard events
(when something is typed in another application) and
Mouse events (everything what the mouse does).
The shell events have one drawback: The name parameter is
identical for all instances of a watched program. You
can only use the
Handle parameter of the event to distinguish
different instances of the same application.
This component is designed for Delphi 2, 3, 4. It is not tested
with Delphi 5.
Note: the source for watchdll.dll is in the project watchdll.dpr.
How to use it
=============
Be sure that only one instance/program uses this component
at any time. You can use TOneInstance for that instance,
you can download that from [
url]http://www.bome.com/[/
url] in the
delphi components area.
Different to previous versions of this component, you
must now call the Start and Stop methods in order to
start / stop watching of a specific type.
Your main program MUST make sure that this component is
freed properly. The easiest way of doing this is to put a
line like "Watch1.Free;" in the main forms OnClose or OnDestroy
event handler. Delphi seems to "forget" to free components'
when closing the application.
Properties:
- NotifyOwnEvents: Whether an event shall be sent when
the own application receives a shell event
- RepeatedEvents: When you activate different windows
of the same application, each time an
event is sent. If you set this to false,
only the first event will be sent.
Events:
- OnActivateShellWindow: Occurs when the shell window is activated
(i.e. the desktop)
- OnWindowActivated: Occurs when any program is activated
- OnWindowCreated: Occurs when a program starts
- OnWindowDestroyed: Occurs when a program closes
- OnKeyNative: A raw key event, occurs everytime something with the
keyboard happens.
- OnMouseDown: Occurs when a mouse button is pressed
- OnMouseMove: Occurs when the mouse moves
- OnMouseUp: Occurs when a mouse button is released
Note on Mouse events:
Even if they contain the ShiftState, the Shift and Ctrl values will
never be set, regardless whether these keys are actually pressed
or not. You could combine it with a key hook to generate the "right"
mouse events.
ideas for enhancements:
- make it usable for multiple applications...
- of course, add the other hooks
- use toAscii in order to get an
Ascii-Character of a key
- let the
dll get some information about the window
in which are typed the keys
- possibility to change messages before they are processed by the
watched application
- let the
dll change specific things while in context
of another program e.g. add to every menu an own menu...
or just get some information about that program
Copyright
=========
(c) 1997-2000 by Florian Bömers
send any comments, proposals, enhancements etc. to:
[email]delphi@bome.com[/email]
new versions on:
[
url]http://www.bome.com/[/
url]