Control your keyboard and mouse with R code by simulating key presses and mouse clicks. The input simulation is implemented with the Windows API.
KeyboardSimulator
Keyboard and Mouse Input Simulation for Windows OS