win32gui SendMessage not working correctly in libreoffice

53 Views Asked by At

I am trying to print a message in LibreOffice Writer with python, using the function

win32gui.SendMessage(window_id, win32con.WM_CHAR, ord('a'), 0)

The expected result in notepad:

Notepad

The result in Libreoffice Writer

Libreoffice Writer

The character "a" was printed 65536 times.

I have also tried using the PostMessage function instead of the SendMessage, as well as the below way of printing

win32gui.PostMessage(window_id, win32con.WM_KEYDOWN, ord('a'), 0)
time.sleep(0.1)
win32gui.PostMessage(window_id, win32con.WM_KEYUP, ord('a'), 0)

The results were the same.

0

There are 0 best solutions below