GithubHelp home page GithubHelp logo

Comments (11)

setvisible avatar setvisible commented on July 20, 2024 4

Hello!

Here a workaround:

import pyautogui
import pyperclip

def _workaround_write(text):
    """
    This is a work-around for the bug in pyautogui.write() with non-QWERTY keyboards
    It copies the text to clipboard and pastes it, instead of typing it.
    """
    pyperclip.copy(text)
    pyautogui.hotkey('ctrl', 'v')
    pyperclip.copy('')

# Test
text_with_special_chars = '@/:;\\.ABCabc?!~^[]{}()'
pyautogui.write(text_with_special_chars) 
# >>> //;\.ABCabc?§¨[]5°      -> NOK

_workaround_write(text_with_special_chars) 
# >>> @/:;\.ABCabc?!~^[]{}()       -> OK :)

It solved the issue on my Windows 64-bits machine / AZERTY french keyboard

from pyautogui.

nguaman avatar nguaman commented on July 20, 2024

in what kind of input do you try to write that? in a input html or in a windows input?

from pyautogui.

PaulBobyrev avatar PaulBobyrev commented on July 20, 2024

In Windows Python IDLE, Notepad, any kind of browsers and text editors. My final goal is to input text a website.

from pyautogui.

asweigart avatar asweigart commented on July 20, 2024

Does the following code work?

`>>> pyautogui.press('1')

pyautogui.keyDown('1')`

from pyautogui.

PaulBobyrev avatar PaulBobyrev commented on July 20, 2024

Yes, both are working for numbers, but doesn't do it for letters

from pyautogui.

asweigart avatar asweigart commented on July 20, 2024

Sorry, I misread. I meant, try pyautogui.press('a') and pyautogui.keyDown('a'). I want to know if the problem is with typewrite() or all the keyboard functions.

from pyautogui.

PaulBobyrev avatar PaulBobyrev commented on July 20, 2024

Never mind. It seems that any keyboard functions related to letters won't work, but works perfectly with numbers. What is even stranger, this issue can be observed both on my laptop and PC, but the only thing that is the same is that both computers works under Russian edition of Windows 7.

from pyautogui.

AlbericC avatar AlbericC commented on July 20, 2024
>>> pyautogui.press('a')
q

looks like the keyboard layout (azerty/fr here) affects typewrite and press

from pyautogui.

MoSchaub avatar MoSchaub commented on July 20, 2024

doesn't work on mac os

from pyautogui.

Tomaubier avatar Tomaubier commented on July 20, 2024

doesn't work on mac os

It does work using pyautogui.hotkey('command', 'v').

from pyautogui.

TSTCodersRoom avatar TSTCodersRoom commented on July 20, 2024

You can try :
with pyautogui.hold("command"): time.sleep(0.1) pyautogui.press("v")

from pyautogui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.