Mouse control with your webcam

Spread the word!

For some reason I got interested into controlling the mouse… without using the mouse. The software I’m going to introduce is the well known¬†Enable Viacam (eViacam), but I would never write a post like this, if the procedure were so straightforward. In fact, while eViacam can be simply used to move your mouse by moving your face (just follow instructions you can easily find in internet), I didn’t like how it handles the mouse click.

But first things first. Step One: Install eViacam from the official website and get used to it. Any object can control the pointer: just reshape the resizeable frame on the region around the object you will use to move the mouse. In the options, you can choose if the pointer should click automatically after a given time not moving. Furthermore, it’s possible to select the type of click from the bar appearing on the top of your screen. But this does not that nice. Instead, what I want is to control the movement using my face and the click using the keyboard. How to implement the second part? I choosed Python to realize the click control. But before talking about that, Step Two (Optional): Choose a couple of Hotkeys as shortcut to turn on/off the software or to center the pointer. You can do it from the configurations of the program.

Now, I want to use the left Ctrl to control the left click and the right Ctrl to control the right click.
Step Three: Install the pyautogui and keyboard modules using pip. I did it from the Anaconda terminal. The first contains click functions. From the latter the pressed keys are detected.

Step Four: Run the following script. It uses the right Ctrl as right click and the Alt Gr for the left Click. By pressing Esc you will enable/disable the script.

If you like, you can run both software and script when your operating system starts, but I will talk about it another time. Maybe.

Be the first to comment

Leave a Reply

Your email address will not be published.