Python Forum
Is there any way to simulate clicks/typing to an inactive window using Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there any way to simulate clicks/typing to an inactive window using Python?
#1
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
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,743 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  Pywinauto typing in the wrong field EGameiro 0 677 Jun-07-2023, 10:01 PM
Last Post: EGameiro
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,167 Jun-13-2022, 08:59 AM
Last Post: Shena76
  Is it possible to make a program recognize how many clicks it has had on the monitor? jao 0 1,152 Feb-25-2022, 06:31 PM
Last Post: jao
  Setup Portable Python on Windows for script starts with double clicks? pstein 0 1,811 Feb-18-2022, 01:29 PM
Last Post: pstein
  Mypy typing error WannaBePythonDev 2 1,925 Sep-05-2021, 10:18 AM
Last Post: WannaBePythonDev
  Is there a way to read the time between clicks? penahuse 1 2,491 Jan-30-2021, 10:46 PM
Last Post: Larz60+
  Typing and variable initializers jgossage 0 1,623 May-29-2020, 03:18 PM
Last Post: jgossage
  What are the available softwares used to edit and simulate network routing protocols? leemao 1 1,909 Dec-25-2019, 05:36 PM
Last Post: Larz60+
  Detect finger clicks/snaps using Python fwinter102 0 2,036 Aug-12-2019, 04:02 PM
Last Post: fwinter102

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020