I am trying to write a python3 script using pynput which presses a key in order to automate a repetitive task I have to do. The code is the following:
import time
from pynput.keyboard import Key, Controller
keyboard = Controller()
keyboard.press(Key.enter)
keyboard.release(Key.enter)
# Press and release space
while True:
keyboard.press(Key.space)
keyboard.release(Key.space)
time.sleep(1)
My problem is that it works, but only in command line. I don't have any idea how to export the input to the open window with the task I have to perform. I am using an OsX system. Thank you in advance.