Input unicode string with pyautogui

前端 未结 3 1488
野的像风
野的像风 2020-12-11 03:07

I\'m creating an autotesting app with pyautogui lib. I want to use typewrite method to input text into forms. But some of my input strings have uni

3条回答
  •  不思量自难忘°
    2020-12-11 03:26

    I tried trestlnord's answer, but it did not work. I adapted the idea to this:

    import pyautogui as px
    
    def type_unicode(word):
        for char in word:
            num = hex(ord(char))
            px.hotkey('ctrl', 'shift', 'u')
            for n in num:
                px.typewrite(n)
            px.typewrite('\n')
    

    works on arch linux

提交回复
热议问题