moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.79k stars 248 forks source link

Long Unicode escape sequences do not work #356

Closed SpecialCharacter closed 3 years ago

SpecialCharacter commented 3 years ago

I encoded superscript Glagolitic A as kbc.type('\u1E000'), but it gave me Ḁ=. When I tried the proper character, it said Type Error.

SpecialCharacter commented 3 years ago

PS: Tried it with '\U0001E000' and '\N{COMBINING GLAGOLITIC LETTER AZU}'. Always Type Error.

SpecialCharacter commented 3 years ago

PPS: Updated to latest pynput version. Error persists.

SpecialCharacter commented 3 years ago

Ḁ is u1E00 (i.e. a zero missing). I do not why he puts = (003D).

SpecialCharacter commented 3 years ago

Sorry, it's Ḁ0, not Ḁ=. So he prints u1E00, 0 instead of u1E000. But when I try the long version U0001E000, it said Type Error. That should not happen, right?

moses-palmer commented 3 years ago

I tested this with the following command: python -c 'import pynput, time; time.sleep(4); pynput.keyboard.Controller().type("\U0001E000")'.

On my system, Linux/XWayland, this prints the expected character. On Windows, unicode is limited to 16 bits in many cases. pynput uses the KEYBDINPUT struct to describe events, and the field designated for the unicode representation of the character is limited to 16 bits since the field wScan is of type WORD.

So, in short, what you are trying to do is not possible using the current implementation in pynput.

SpecialCharacter commented 3 years ago

OK, so at least I am not crazy... Is there a temporary fix? Using a different entry method than KEYBDINPUT?