Disabling the Mouse and Keyboard for attended bots using Automation Anywhere
One of the challenges of developing attended bots using Automation Anywhere is to prevent the user from interfering with the bot's actions. If the user moves the mouse or presses a key while the bot is running, it may cause errors or unexpected results. To avoid this, we can use a simple trick to disable the mouse and keyboard for the duration of the bot execution.

The trick is to use a Windows command called nircmd, which is a small utility that can perform various actions on the system. You can download nircmd from here: https://www.nirsoft.net/utils/nircmd.html
Once you have downloaded nircmd, you need to copy it to a folder that is accessible by the bot, such as C:\Windows. Then, you can use the Run Program command in Automation Anywhere to execute nircmd with the following parameters:
- To disable the mouse and keyboard: nircmd.exe sendmouse move 0 0
- To enable the mouse and keyboard: nircmd.exe sendmouse move 1 1
The first parameter, sendmouse, tells nircmd to send a mouse event to the system. The second and third parameters, move 0 0 or move 1 1, specify the coordinates of the mouse movement. By moving the mouse to (0,0) or (1,1), we effectively disable or enable the mouse and keyboard, since they will not respond to any user input.
To use this trick in your bot, you need to add two Run Program commands: one at the beginning of the bot to disable the mouse and keyboard, and one at the end of the bot to enable them again. For example:
- Run Program: C:\Windows\nircmd.exe sendmouse move 0 0
- Perform your bot actions
- Run Program: C:\Windows\nircmd.exe sendmouse move 1 1
This way, you can ensure that your attended bot runs smoothly without any user interference. However, you should also consider adding some error handling and exception handling mechanisms in your bot, in case something goes wrong and you need to abort the bot execution. For example, you can use a hotkey trigger or a message box to stop the bot and enable the mouse and keyboard again.
Disabling the mouse and keyboard for attended bots using Automation Anywhere is a simple but effective technique that can improve your bot performance and reliability. You can also use nircmd for other purposes, such as changing the screen resolution, adjusting the volume, taking screenshots, etc. You can find more information about nircmd and its parameters here: https://www.nirsoft.net/utils/nircmd2.html
Comments