[Python] Why does pyautogui.write() skip Polish characters like "ś" , "ą" when typing into...

Discussão em 'Python' iniciado por Stack, Setembro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I'm automating a legacy system on Windows using, among other things, pyautogui. Everything works fine except one major issue: customer names with Polish characters like ś, ż, ł, etc., are typed incorrectly into the program.

    When my automation types names like "GRZEŚ", what gets entered into the application is "GRZE". The ś character is skipped or not typed.

    The name comes from a merged Excel/CSV file, and the correct Polish name is present in the dataframe. It prints correctly in logs and variables, but is not typed properly into the UI.

    I want pyautogui to type the full name with Polish characters, e.g.:

    GRZEŚ

    But I get:

    GRZE

    This is a simplified version of what I'm doing:

    import pandas as pd
    import pyautogui

    df = pd.read_csv("work/out/merged_output.csv", delimiter=";", dtype=str)

    for idx, row in df.iterrows():
    name = row["CONTRACTOR_NAME"]
    amount = row["COST"]

    print(f"Typing: {name}") # <- This prints correctly, e.g., 'GRZEŚ'

    pyautogui.click(200, 300) # click into the right input field
    pyautogui.write(name) # <- This types 'GRZE'
    pyautogui.press("tab")
    pyautogui.write(amount)



    I confirmed that the variable contains the correct Unicode string. It prints as expected and saves to a file correctly.

    I have:


    • Verified that Polish characters like ś, ł, ć load correctly from CSV and display properly in print() and logs.


    • Normalized names only during matching (using unidecode), but kept original values for typing — didn’t help.


    • Confirmed that records contains correct names like "GRZEŚ" just before typing.


    • Added UTF-8 encoding to read_csv() and to_csv() - no change.


    • Slowed down typing using interval=0.1 but it still skips special characters.


    • Considered using clipboard paste (Ctrl+V), but prefer direct typing if possible

    What's the best way to reliably type Unicode characters (like Polish ś, ł, ż, etc.) into a Windows application using Python automation?

    Continue reading...

Compartilhe esta Página