Python Forum

Full Version: Is there any way to simulate clicks/typing to an inactive window using Python?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
By the way, I'm a windows user. A lot of windows-automation scripting programs have this function (although not always effective) so I was wondering if it can be implemented in Python, or I will have to collaborate two scripts from two different languages.

Also do note that I am a complete newbie to programming itself so I won't understand any technical terms, in fact I have not even read most of the tutorial (from docs) yet (yes I'm lazy. So I would appreciate if you give more context like a brief description and suggestions.

Also, would it also be possible to do this on Mac? And since we're at it, would it also be possible in Android and IOS?

Anyways, I appreciate that you read the thread. Wink
Here's one way:
first install https://pypi.org/project/PyAutoGUI/
use:
pip install PyAutoGUI
then to emulate a mouse click:
import pyautogui

pyautogui.click()
You can look at the source to see how it's done.

If this is being used in response to an interactive query, you might want to examine expect: https://github.com/sumeet/expect
expect was written by Don Libes of NIST and has been around (for 'C') for a long time. Great for automating demos.

This can be installed with pip as well