Search code examples
pythonpyautogui

Missing symbols in Pyautogui typewriter


I have a problem, that consists in following: Pyautogui typewrite won't type letters, only numbers. For example, when I execute

pyautogui.typewrite("abc123")

only "123" appears. This question is similar to this one: Pyautogui typewrite is writing only numbers Unfortunately, there are no answers about the issue, as well as other Internet topics. I have the Windows 7 machine and Python 3.5.


Solution

  • There seems to be a bug in the typewrite function of PyAutoGui. I workaround it with this function which preprocesses the string into keypresses instead. Note that this version of the function leaves a comma at the end of the output array so that you can easily append more characters or button presses at the end.

    def preprocess(something):
        something = str(something)
        output = []
        for x in range(len(something)):
            output.append(something[x])
            output.append(',')
        return output