Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some characters are not working with German layout keyboard #46

Closed
E2w4UmWh opened this issue Aug 18, 2015 · 8 comments

Comments

@E2w4UmWh
Copy link

commented Aug 18, 2015

I do have a strange problem, using a German keyboard layout.

pyautogui.typewrite("!"#$%&()+H")
!"'$%&()
*H

Which means '#' results in an ' and '+' results in an *.
This is quite strange, as all other characters seem to work.

The software, I'm targeting to, is very dumb. It does not accept 'CTRL'+'V' nor 'ALT'+'35' in it's text fields, so I really have to simmulate single keystrokes. Unfortunately I do need the Hash # sign to trigger some actions.

OS: Windows 8; Python: V3.4.3

Are there any ideas for a work around? Anny suggestions appreciated!

@E2w4UmWh

This comment has been minimized.

Copy link
Author

commented Aug 19, 2015

I had time to dig a bit deeper into that problem and found the following: The characters wrongly showing up are always the one, showing up when shift is pressed wrongly (on a real keyboard):
#:' , +:* , <:>

Putting the characters into 'keyboardMapping' first, did not have any effect. As a successfull workaround, then I patched the following code in _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

This has SOLVED my problem with some special characters and hopefully may help others, with non-US keyboards.

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

@Tattoo

This comment has been minimized.

Copy link

commented Aug 28, 2015

It would be great if pyautogui would support other keyboard layouts than English. I'm willing to help with implementing the Finnish layout

@Semmu

This comment has been minimized.

Copy link

commented Dec 30, 2015

Same problem here using Hungarian layout, # results in +, and + results in (. Other anomalies may exists too, I didn't test every key.

I'm willing to help in the Hungarian mapping. (or find a keyboard-layout independent solution? don't know if there is any)

@georgemunteanu

This comment has been minimized.

Copy link

commented Jan 14, 2016

hello guys. on german keyboard, I faced this problem. Character "" is converted into character "?" . I tried the suggestion mentioned above ( that is altering: pyautogui_win.py > def_keyDown ), but "" is still converted into "?".. Therefore please share a hint on this.

@i-need-to-tell-you-something

This comment has been minimized.

Copy link

commented Feb 29, 2016

In my case a similar problem seems to be connected to what these (Estonian) keys are on an en_US keyboard (with the exception of skipping Estonian magnificent vowels üõöä). E.g. these:

"test !"#¤%&/()=?`PÜÕ*LÖÄ;:_ 1234567890+´püõ'löä,.- "

get typewrited as these:

test !@#%^7()0_=P|L,>? 1234567890_p\l,./

In my case it worked fine when i was using the full KDE environment, but when im only using Xmonad window manager, it starts aforementioned mistyping behaviour (i.e. i have a window manager, but no desktop environment). I can type these fine manually, and print works fine too, just nothing from pyautogui.
Im on Kubuntu 15.10, Xmonad, 4.2.0-30-generic, Python 3.4.3+, GCC 5.2.1 20151010
EDIT: apparently this problem also appears on xdotool

@i-need-to-tell-you-something

This comment has been minimized.

Copy link

commented Mar 1, 2016

So i dug deeper and learned that the problem underlying my issue had a workaround (execute setxkbmap after every boot) mentioned here. Newer bug reports are here for that similar tool having the same issues.
EDIT: oopsie, didnt notice that OP is not on Unix.
EDIT2: It seems everything was using US keyboard due to Xmonad. So in my case this wasnt a pyautogui problem.

@margilc

This comment has been minimized.

Copy link

commented Mar 17, 2016

I had the same problem as georgemunteanu, and found a workaround which should be applicable to all non-english keyboard problems with autogui on windows. For further information look here:
http://stackoverflow.com/questions/36040370/encoding-of-backslash-in-pythons-pyautogui/36055972#36055972

@asweigart

This comment has been minimized.

Copy link
Owner

commented Mar 19, 2017

Folding this into issue #137

@asweigart asweigart closed this Mar 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.