The following fails to print a hashtag?
import pyautogui
pyautogui.typewrite('#');
It prints '~'.
As Sean Kennedy said, it's a keyboard layout issue. They're still working on support for non-US-English keyboard layouts.
https://github.com/asweigart/pyautogui/issues/137
Luckily you have an English keyboard layout, so you'll have far fewer issues and you should be able to patch them. You can redefine whether certain keys need shift or not by editing _pyautogui_win.py
:
def _keyDown(key):
if key not in keyboardMapping or keyboardMapping[key] is None: return
needsShift = pyautogui.isShiftCharacter(key)
# insert this code, exactly here:
if key == '#': needsShift = False
if key == '+': needsShift = False
if key == '<': needsShift = False
#print(key,needsShift) #####debug
# continue
Taken from: https://github.com/asweigart/pyautogui/issues/46#issuecomment-132640299
I haven't looked at the code myself, but you might find that you're better or worse making the edit inside isShiftCharacter
.
I should have kept reading. isShiftCharacter might become a rabbit hole:
By the way: Deleting #,+,< in the following function, did NOT work (util.py in .\pyautogui):
def isShiftCharacter(character): return character.isupper() or character in '~!@#$%^&*()_+{}|:"<>?'
Maybe .isupper() regards these characters as upper? I didn't check further