This week, in my spare time, I decided to learn a little more about Haar Cascade. Specifically, how some face detection works and it’s implementation with C++ OpenCV.




     After a little research and brainstorming, I started a software for moving the mouse using only the head. With this approach, I needed to learn some

<Windows.h>, a thing I always wanted and never had the opportunity.

 

The <Windows.h> mouse problem

     When I started, I realized some <Windows.h>mouse functions seemed pretty basic, often needing additional parameters to do underlying actions. For instance, to correctly set the mouse position to the top right to every resolution, the screen size must be known, and it demands additional computing that is not conveniently available. Let me show a way for doing it:

 

  • First, a Rect struct needs to be declared: RECT DesktopRect;
  • Then, a Window’s Desktop Window Handle to obtain the current resolution:

 

  • Now, having the screen information, it’s possible to send the mouse cursor to the desired location: SetCursorPos(DesktopRect.right,0);

 

      Figuring out which functions and how to use them can be a painful process, So why don’t make it easier? For that, I developed a small, yet useful, C++ Windows library called SimpleWMouse for doing actions like:

  • Smooth X and Y movement;
  • Click simulation;
  • Active button verification.

     It’s available in an initial stage on my Github.