I'm trying to make a script that runs in the background while I use the main window. It has been done before, and I have seen it. Every time I try this code, it moves the notepad to the front which makes me unable to use the main window properly. Any suggestions? Also, I'm trying to use the mouse to detect something and the print is just as an example.
Code:
from pywinauto.application import Application
import time
# Replace 'Notepad' with the actual executable name or window title
app = Application().connect(path='notepad.exe')
# Reference the window by its title
window = app.window(title='Untitled - Notepad')
# Wait for a few seconds to give the script time to run in the background
time.sleep(5)
# Perform interactions without bringing the window to the foreground
# Example: Type "Hello, world!" into the Notepad
window.type_keys("Hello, world!")