Mouse Mover

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!

Be the First to Share

    Recommendations

    • First Time Author Contest

      First Time Author Contest
    • Tinkercad Student Design Contest

      Tinkercad Student Design Contest
    • Robots Contest

      Robots Contest

    8 Comments

    0
    mihaitintea
    mihaitintea

    11 months ago

    why specifically "beetle" and not just any kind of tiny-enough-for-reasonable-taste-small microcontroller ?

    0
    ljohann
    ljohann

    Reply 10 months ago

    The device needs to have a mouse functionality. I don't know of any smaller microcontroller/device which has this build on board so that you can use it out of the box.

    0
    danielg194
    danielg194

    11 months ago

    can this beetle be used in a raspberry pi aswell

    0
    ljohann
    ljohann

    Reply 11 months ago

    Should be no problem to use it as a mouse or keyboard on a pi.

    0
    memjr73
    memjr73

    1 year ago

    If you're running Windows, you can run this PowerShell script.

    $WShell = New-Object-com "Wscript.Shell"
    while($true) {
    $WShell.sendkeys("{SCROLLLOCK}")
    Start-Sleep-Milliseconds100
    $WShell.sendkeys("{SCROLLLOCK}")
    Start-Sleep-Seconds 59
    }

    0
    ljohann
    ljohann

    Reply 1 year ago

    Thanks! Unfortunately, the computer I am using the external Mouse Mover for, is configured to not run any scripts. If I had the administrator rights to do so, I probably could also change the screensaver settings...

    0
    memjr73
    memjr73

    Reply 1 year ago

    Are you not able to go to Start -> Run, then enter powershell? If you can do that you'll be able to type the script in by hand.

    0
    ljohann
    ljohann

    Reply 1 year ago

    Like I said - no rights to that machine. Script blocking is of course an essential security feature. I would not complain and find a way out of it if I was not forced to run that thing at home which I consider a safe workspace.