Having worked in corporate America for the better part of 40 years, I’ve seen corporate computer security policies change over that time from almost none to nearly insane. Today many IT groups force the computers they maintain to require a password to be entered if the computer goes to sleep, which can occur in as few as 5 minutes, in some cases. A recent employer of mine also went to a two step authentication scheme using your password and a token device that displays a set of numbers that also have to be entered as a second password. While this security is nice and sometimes essential, it can be very annoying if you actually need to get something done (besides entering passwords). I can’t count the times I’ve been interrupted at my desk by a conversation with a co worker only to find that when I get back to my computer, the screen has gone to the lock screen and I have to enter the password and a token value to continue. It would be nice to have a mechanism to occasionally automatically move the mouse a little to keep the computer from going to sleep and the lock screen.
Searching the web for a solution to this revealed that others have attempted to solve this problem. Everything from a servo that physically moves a real mouse to software programs that run on the PC as a background task were found to do this function. The servo method seems far too primitive, while the software only PC program versions don’t always work because the security rules “see through” this cheap trick. What would be nice is to come up with a low cost device that “looks and smells” like a real mouse, that occasionally moves. This lead to the development of the “MouseMover” device detailed here.
******************************** DISCLAIMER *******************************
This firmware and its associated device can be used to override corporate IT department directives and security mechanisms in place by keeping the system from going back to a lock screen. This may not be allowed in a corporate or government environment and may result in mild to severe penalties. If in doubt, check with your IT department before using this device. Use this device at your own risk.
******************************** DISCLAIMER *******************************
Project DetailsThis project implements a simple “MouseMover” that can be used to keep a computer from going to sleep or locking using only a low cost (≈$5-$17) Pro Micro module (Sparkfun DEV-12640 or equivalent clone) with an ATMega32U4 processor chip, a USB cable and software implemented using the Arduino IDE compiler and environment. It can also be used on other Arduino controllers like the Arduino Leonardo or Arduino Micro, but the Pro Micro board is tiny, powered by the USB port and low cost, making it the ideal hardware solution for this task.
This controller moves the mouse cursor a tiny amount every minute or so, simulating the user being at the computer, which prevents host PC from going to sleep or locking the screen. Unlike software only solutions that many IT infrastructure systems know how to ignore, this solution looks as though a real (second) mouse is added to the computer. The normal mouse is still used for computer operation.
Usually moving the mouse cursor a few pixels every minute or so is enough to keep the computer from going to sleep or locking. Because the amount moved is small (even just a few pixels in either the X or Y direction is usually enough) and it’s only is done every minute or so, this will not usually interfere with normal computer operation. To maintain some semblance of system security (that IT groups demand) this added mouse controller can be programmed to only run for a limited time, after which it stops moving the mouse, until commanded to run again (or unplugged and re plugged in again).
This controller has a number of user changeable parameters. All of the parameters for the controller can be modified by sending commands to the controller’s serial port, which is also added to the host PC when the controller is plugged in. This controller will appear to Windows as a mouse device (HID) and a virtual serial com port. Once the controller is programmed, it will have default parameters selected for all of the changeable parameters, but these can be changed and then saved to EEPROM so that the user selected parameters are used each time the controller is connected to the PC.
This firmware is designed for use with a Pro Micro board (that uses an ATMEGA32U4) and is connected to the PC with its USB port. With this concept, the only hardware required for this solution is an Arduino Pro Micro controller and a USB cable that connects this controller to the PC.
Hardware and I/OWhile this project requires no hardware or wiring other than the Pro Micro module and the USB cable to hook it up to the computer, there are a few of the I/O pins that can have jumpers added to alter the devices operation. There is another pin that can have an LED connected to it to indicate that it’s running or not, if desired. While not required, it has been found that having the LED connected is a handy addition – It’s nice to know when the MouseMover is running and not. The other connections to the jumpers are mostly provided as a convenience, or if control of the MouseMover by jumpers is desired instead of using serial commands.
A drawing of the various optional I/O connections is shown below.
One jumper called JPE (defined in the code) can be used to disable the controller. By grounding this pin, the mouse functionality will stop (as though you unplugged the mouse) and will be restored when the jumper is removed. This jumper is on Arduino pin 6 [PD7].
A second jumper, JP2 (defined in the code), if grounded, will disable the software run timer and keep the mouse "running" all the time, no matter what the programmed run time is. Remove the jumper to restore normal operation. This jumper is on Arduino pin 2 [PD1].
A third jumper, JP3 (defined in the code), if grounded, will cause the mouse to move every 5 seconds, instead of the configured move time. Remove the jumper to restore normal operation. This jumper is on Arduino pin 5 [PC6].
An LED and resistor can be added between pin A3 (Arduino Digital pin 21 [PF4]) and VCC to indicate when the MouseMover is running (Pin is labeled "A3" on the Pro Micro). While not required, it is handy to have this indicator so that you know if the MouseMover is running or not (on or off). The LED can be any LED you might have. The resistor shown is a 330 ohm 1/4W part, but any resistance from about 100 ohms to 1K would be usable, depending on the LED used. There are also LED’s available with a built in resistor, such as Lumex SSL-LX3044GD-5V (Digikey 67-1062-ND) that are designed to run directly from the 5V supplied by the module. Using this type of LED simplifies connection to the module – Just solder the two leads of the LED to the two pins indicated. For any LED, be sure to observe the polarity of the LED – The cathode end goes to pin A3 and the anode goes to the resistor and VCC.
Compiling Firmware and Downloading CodeLoad the code for this project by creating a MouseMover directory in your Arduino folder and put the file MouseMover.ino in this folder. Double click on the file to start the Arduino IDE and then set up the "Tools" section as shown.
Board: Arduino Leonardo (This can be used for Pro Micro also)
Port: COMxx (as it is assigned by your system)
Programmer: ArduinoISP.
If the Pro Micro device has already been used on the computer system that the Arduino IDE is installed – Just press the “Upload” button once the file is loaded in the IDE. If this is the first time that the Pro Micro module is being connected to the computer, you will have to install the device driver for it.
See the documentation PDF in the github MouseMover repository for further details on installing the Pro Micro device on your computer, changing the com port number and possible problems that may be encountered while downloading code after the Pro Micro device is first installed.
This project was developed using Arduino IDE version 1.8.5. Newer versions, including the latest (Vers. 1.8.15) should also be able to be used without issue.
Software CommandsThis controller accepts serial commands to perform various functions and report current settings. Open the com port with any baud rate (other than 1200 baud) (N, 8, 1) using a program like Hyperterm, Teraterm, or the terminal window in the Arduino IDE (or your favorite terminal program). Later you can also create batch files to send commands to the device via the com port.
Once you have verified that communications to the MouseMover are working (You can send “?” and <Enter> and see a help screen), you can then send commands to the MouseMover and set up its parameters, if desired.
The commands for the MouseMover are detailed next. Commands are a single letter (to read the value) or a single letter followed by a number (to set the value) and <CR>.or <CR><LF>, as in X<CR> or X20<CR> (Can also be X=20<CR>) (Note: <CR> is the “Enter” key).
If you want to alter the variables “X”, “Y”, “T”, “R” and then save them as the new default power up values, just set them to new values and then enter “E2<CR>. To restore them to original default values enter “E0<CR>” and then “E2<CR>”.
System IntegrationOnce the Pro Micro module is programmed with the MouseMover firmware it can be used in your system with various levels of integration.
The simplest use is to merely plug it in to a USB port when you want it to function and unplug it when you don’t want it to function. Each time it is plugged in it will run using the parameters that are saved in EEPROM, which include the amount of time to run. After the MouseMover hardware has been plugged in for the amount of time to run that is programmed, the MouseMover will stop, allowing the computer to go to sleep/lock. By simply unplugging it and then re plugging it in again, a new run time will be used again. Using this method, the user can program the MouseMover with the amount of time to run and then plug it in each day for that amount of “run” time.
Windows Batch file and Automation.Instead of plugging and unplugging the MouseMover, a batch file and various shortcuts can be created to enable/disable the device. You can then also set up a task in Windows to call this batch file at whatever time you specify or when you log in. These have been created for Windows 7 and Windows 10, but can be converted for Apple or Linux/Unix systems.
You can create a batch file to send a “Run” command to this device as follows:
@echo off
rem MoverPort is comport address in format \\.\COM# (set to your comport#)
set MoverPort=\\.\COM4
rem R=<# minutes to run> (9 hours=540) (0=off)(%1=get from cmd line)
echo R=%1 >%MoverPort%
Note: Replace “COM4” in the above batch file with the COM port number used on your machine.
A suggested name for this batch file is “MouseMover.bat”
Then call the batch file with a parameter as in:
MouseMover 540
(This will set the runtime to 540 minutes)
MouseMover 0
(This will turn off the MouseMover)
With the batch file created and placed in a directory of your choice you can then create a Windows shortcut to call this batch file by merely double clicking on the shortcut icon. To create the shortcut, right click on the batch file and click “Create Shortcut”. You can then rename the short cut to a more recognizable name such as “StartMouseMover” or “StopMouseMover”. Once renamed (if desired) you can edit it to send the amount of time to run by entering a number at the end of the command already in the “target” box. Then, if desired another shortcut can be created to turn MouseMover off by copying the already created shortcut and then changing the parameter to zero. Once these shortcuts are created, you can just double click the shortcut(s) to turn on the MouseMover for the amount of time you specified in the shortcut file or turn it off if the time in the shortcut is zero.
Further automation can be accomplished by to creating a Windows Task to call the batch file either at scheduled times or when the user logs on to the computer. This can either be done by running the Windows task scheduler and creating a new task or by typing a command on the command line in a CMD box to create the scheduled task. See the documentation PDF in the github MouseMover repository for further details on how to create a task to do this.
In my use of this program I found that setting up a task that runs each time you log in to the computer works best (instead of a fixed time schedule). Using this method, you sign in each morning one time and the computer will stay running for the next number of hours programmed and then will go to sleep/lock. With the Windows batch file and the task, you can leave the MouseMover plugged in all the time and just ignore it – It just works and you’ll never be bothered by having to log in more than once a day.
ConclusionIt is hoped that the use of the MouseMover will eliminate one of the “inconveniences” of the IT imposed security measures. Please heed the disclaimer if using this device in a corporate environment. Obviously you can also use it on your home computer as you see fit.
The more detailed documentation file mentioned in this project along with the Arduino sketch file is located at https://github.com/Rick-G1/MouseMover and is part of the zip file that you can download from there.
******************************** DISCLAIMER *******************************
This firmware and its associated device can be used to override corporate IT department directives and security mechanisms in place by keeping the system from going back to a lock screen. This may not be allowed in a corporate or government environment and may result in mild to severe penalties. If in doubt, check with your IT department before using this device. Use this device at your own risk.
******************************** DISCLAIMER *******************************
Comments