Introduction: Mouse Mover

About: Living and working in Berlin

Moving a mouse pointer automatically before the screensaver locks the screen.

Step 1: The Problem

Staying at home as much as possible is recommended in pandemic times. Unfortunately, the computer that was configured by my company for home office is very limited with regard to features that can be changed. As I am working in parallel on a second computer, one annoying feature is the screensaver that starts after 5 minutes idle time and shuts down the system completely. Sure, this is a reasonable security feature that would make very much sense in a public area. Please note that I am not recommending this little workaround for anyone not working in a safe and trustworthy environment!

Step 2: The Theory

In order to prevent the screensaver from starting all we need is a quick mouse movement every 5 minutes. There is a neat software solution for this called MoveMouse (https://move-mouse.en.softonic.com/) that does the trick - if only I was allowed to install any software on the damned laptop. So what we need is an external USB mouse that automatically moves from time to time.

Step 3: The Solution

I recalled that the ARDUINO Leonardo can simulate mouse and keyboard inputs, but the Leonardo is a bit big and clumsy for that purpose. Luckily, there is a very small ARDUINO compatible board called the "Beetle" that is very small and does the trick. I ordered a "beetle" and set up a very small program that moves my mouse every 229000 milliseconds, so to the least one second before the screensaver hits in. I know that the program could be much more sophisticated. For example one could read out the time of the last mouse movement and only start the movement if necessary. I deliberately did not include any reads from the system and kept the script simple "input only" for not violating my companies terms of use. Also, as said above, I only use this "special mouse" when I am in a safe environment where no unauthorized person can gain access to the computer.

Step 4: Programing Arduino

There are numerous tutorials here on how to set up the ARDUINO programing environment. Please follow the directions in any of those tutorials.

https://www.instructables.com/id/A-Beginners-Guide-to-Arduino/

All you have to do is choose the Leonardo board and the USB port the beetle is connected to.

Step 5: The Code

/* Move the mouse pointer just before the screensaver starts */<br>#include "Mouse.h"
unsigned long wait = 0;
unsigned long interval=299000; 
int responseDelay=100;
void setup() {
  Mouse.begin();
}

void loop() {
 if ((unsigned long)(millis()- wait) >= interval) 
 {
  Mouse.move(10,0,0);
  delay(responseDelay);
  Mouse.move(0,10,0);
  delay(responseDelay);
  Mouse.move(-10,0,0);
  delay(responseDelay);
  Mouse.move(0,-10,0);
  wait=millis();
 }
}

Step 6: Caution

The "beetle" basically can be used to program a "Bad USB" or "Rubber Ducky". Such devices are intended to allow injecting a computer with mouse moves, clicks, and keyboard commands. I will not go into details, how to program such malicious behavior. Just be aware to not insert any unknown USB into your computer!