Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Utility to capture mouse & keyboard hook from Windows OS

User Story:

As a developer I want to Create a console application which create a global Windows OS mouse hook, to collect the following information on every click done across any application running and print the following info on console:

  1. Mouse coordinates in pixel
  2. Exe of the application running behind the cursor
  3. Get the focused element type on the running behind application.

This application captures the any mouse click events from any windows application and shows below output

explorer.exe: {X=1108, Y=1063}:MSTaskSwWClass notepad++.exe: {X=592, Y=-1045}:Notepad++ notepad++.exe: {X=635, Y=-840}:Menu Item notepad++.exe: {X=959, Y=-366}:Button Key Pressed: 91 EXCEL.EXE: {X=651, Y=-741}:EDTBX

The code has been made expandable and also added provision for more events like keyboard events with example.

Architecture

When designing a utility to capture mouse and keyboard events from the Windows operating system, desided to consider using the Observer design pattern.

The Observer pattern is a behavioral design pattern where an object, known as the subject, maintains a list of its dependents, called observers, that are notified of state changes.

Here's how applied the Observer pattern in this context:

  1. Subject (Event Broadcaster): This could be a class responsible for capturing mouse and keyboard events. It maintains a list of registered observers and notifies them when events occur. There can be multiple observers for one bradcaster. There are two Event broadcaster classes are implemented and can be exteded for multiple classes
  • KeyboardEventBroadcaster
  • MouseEventBroadcaster
  1. Observer (Event Listeners): These are classes that are interested in receiving notifications about mouse and keyboard events. They register themselves with the subject and get notifications about events. There are two Event Listeners classes are implemented and can be exteded for multiple classes
  • KeyboardEventLogger
  • MouseEventLogger

Observer classes names given as logger in this application context, here responsibility of class is to listen the event and log events on to the console.

UML Class diagram

image info

Demo

Demo video Link Here

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages