简体   繁体   中英

pyautogui cannot write the @ symbol

I've been trying to produce the "@" character with pyautogui:

import pyautogui
pyautogui.typewrite("@")
pyautogui.typewrite("\x40")

But I can't seem to make it type a "@" in any way.

My keyboard uses AltGr + 2 to create an "@" symbol, but I haven't been able to make that work either.

pyautogui.hotkey('altright','2')

I did not find a way to do it with the write method, but in some scenarios you could work around it by putting the @ on the clipboard and paste it:

import pyperclip
pyperclip.copy('@')
pyautogui.hotkey('ctrl', 'v')

use the hotkey function

from pyautogui import hotkey
hotkey("alt","l")

This is what works for me on mac, you will know your windows shortcut to write an @ symbol... ;)

Neither of the suggested solutions work for keyboard layouts that isn't the standard US keyboard layout. The problem is that pyautogui doesn't really handle different keyboard layouts that well. Switching to standard US keyboard layout in your OS should solve any issues with special characters.

也许您可以尝试更改键盘布局:$ setxkbmap us

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM