I am a student and a novice in python. For a project I have to read and write to the Microsoft Office Word GUI using Python. I know it would be easier writing and reading directly to file with python- docx but it can't be helped. (A la programmers perspective not user perspective) The supervisor wants it that way.
I found following threads which aren't that helpful because I don't know C and how it connects to Ctype. Interact with other programs using Python Obtain Active window using Python
The typing and standard input part is easy and I have it nearly implemented. The problem is making the MSWord GUI the active window while pynput is running. I have no clue.
from pynput import keyboard
from pynput.keyboard import Controller, Key
def press_enter(start_number): # The event listener will be running in this block
keyboardinput = Controller()
with keyboard.Events() as events:
for event in events:
if event.key == keyboard.Key.esc:
break
elif event.key == keyboard.Key.enter:
#doing some things when enter is typed
else:
print('Received event {}'.format(event))
Could somebody point me in the right direction which libraries and docs I have to read?