Search code examples
python-2.7python-3.xkeyboardmousepyautogui

Pyautogui commands are working even when no mouse or keyboard is connected


I wrote a script with python-pyautogui to automate mouse and keyboard actions. Mouse and keyboard commands are working as per script when keyboard and mouse are connected. I wondered, it still works even when they are not connected. if so it is as per design, may i know how to set the condition to execute the script only if keyboard and mouse are connected??

Kindly share your ideas. Thanks in advance..


Solution

  • PyAutoGUI will still work if there's no keyboard or mouse connected. However, PyAutoGUI does not have any way to detect if a keyboard or mouse are connected to your machine.