MouseGestures: Enhance your application with mouse gestures

Current version
v0.2.1, 2005-04-25
Download (201KB), Delphi 5 source code and demo application included.
freeware, open source
The MouseGestures DLL is a library that enables you to enhance your application with mouse gestures. It is intended for application developers, not end users.
Operating systems/languages
Windows. Reported to work on Win2000, WinXP, Win95. The project could also be successfully compiled with Delphi 4.
Thanks to Holger Schieferdecker for testing Win95, D4
It should work with any language capable of binding to dynamic link libraries such as C++, C#, Object Pascal (Delphi), …
MouseGestures.dll is freeware that comes without any warranty or support. Thus you use it at your own risk. You may even use it in commercial products as long as you mention me as original author somewhere. If you make modifications to the source code, you must maintain the original copyright notice and publish it under the same licence. For the exact conditions, see LICENCE.txt that is contained in the download package.


The first time I stumbled over mouse gestures was when Opera Software ASA introduced them for their web browser Opera.

They are an ingenious way of enhancing a simple computer mouse. A mouse gesture is a specific movement of the mouse while you hold down your right mouse button.

So, to execute the down-right gesture, for instance, you’d press and hold the right mouse button. Then move the mouse down and right. When you release the right mouse button, the gesture is completed. If you registered the down-right gesture with your application, yout application is notified about the gesture.


Just link the DLL to your programme and register the mouse gestures to your liking. The README.html file in the download package contains a more detailed information, so I’ll just point out the main features below.

Basically, it’s just calling RegisterGesture for each gesture you want to respond to, then enable gestures with GesturesOn. The library cleans up the registered gestures when it is unloaded, but if you want to do this yourself, you can call GesturesOff and UnregisterAllGestures.

  • Register mouse gestures: Each gesture is identified by a string and a “start handle” (the window handle from the control where you started the mouse gesture)
  • Currently, the four main directions can be distinguished: Up (U), Right (R), Down (D), Left (L). In addition, you can define modifiers to gestures, like ‘a’ for the Alt key, ‘c’ for Ctrl, ‘s’ for Shift.
    Examples: DR … down-right; aDR=DRa=aaaDR .. Alt plus down-right
  • Mouse wheel gestures (W for movement towards the user and M for moving away from the user): click and hold the right mouse button then use the mouse wheel. You can determine the behaviour of the wheel gestures to either work as the regular gestures (triggered when the user releases the right mouse button) or to instantly react to scrolling.
    Examples: aW … Alt + wheel towards you; M … wheel away from you. If you decide not to trigger immediately, you can also use WMW or aMW or similar gestures.
    Note: Mouse wheel recognition is implemented for Win2k or later only.
  • Mouse gestures trigger sending of messages: The message that is sent when a registered mouse gesture was performed is determined by the receiving window handle, the message itself and the wParam.


2005-04-25 — 0.2.1
Bugfix: Mouse wheel handling was erroneous.
2005-04-23 — 0.2
Improved system performance by attaching the DLL only to your own thread/process (See GesturesOn in README.html)
(bug)fix: Only mark the message as handled, if we actually did something. This fixes popup menu issues.
Mouse wheel integration for gestures.
Implemented gesture modifiers (Alt, Ctrl, Shift)
2005-04-05 — v0.1
Published v0.1


I’d like to thank Marian Aldenhövel for the initial spark to implement this module at all as well as Michael Winter and Torsten Munkelt for their precious comments in the news group de.comp.lang.delphi.misc.