book collections email follower instructable user

Step 3: Mouse Maps

Picture of Mouse Maps
PiNG Setup 2_Moment.jpg

If Duo were a full app then command line options might be available, for example to launch the app and immediately call a specific contact. In the absence of this (for now?) I needed to find a way to automatically start a call with a GPIO button press.

To do this I used the Python module PyUserInput which lets you program mouse movements, clicks and keyboard strokes.

The idea was to set up a script to wait for a button press, then move the mouse to the "Contacts" textbox, type the name of the contact, press "Enter" and click "Video Call". Duo remembers the last person contacted and shows them in the centre of the screen, but I didn't want to rely on this in case the doorbell called the wrong person (which happened in testing - sorry Harry)!

It took some trial and error to get the mouse to click in just the right place (having the app full-screen helped) and finding the right keystroke to emulate the "Enter" key was the same, but it was a lot of fun. On the GitHub page there's also a little script called Position.py that displays the mouse co-ordinates, which was very useful.

With this resolved, I then added in some more code to kick off the mouse moves based on a GPIO button click. This worked very well in testing, once the call had been hung up on the phone the Pi went back to its original screen, so when the doorbell button was pressed again it would repeat the same action.