moses-palmer / pynput

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

MacOS/Quartz: how do I get more than one character from getunicodestring? #523

Open SpecialCharacter opened 1 year ago

SpecialCharacter commented 1 year ago

Description In Quartz: how do I get more than one character from getunicodestring?

For reference: https://developer.apple.com/documentation/coregraphics/1456120-cgeventkeyboardgetunicodestring

Do I have to change the None?

length, chars = Quartz.CGEventKeyboardGetUnicodeString(
        event, 100, None, None)

Platform and pynput version MacOS Catalina 10.15.7 pynput version unknown

To Reproduce

# S e t s the Unicode string associated with a Quartz keyboard event (= Transform).
        if length > 0 and chars == 'whatever':

length > 0 will not work with a multiple-character string, but neither will length == 8. Any solutions?