PyUserInput
PyUserInput copied to clipboard
printing @ signs
I have a problem printing the "@" sign when using type_string. Anyone knows why? I have UTF-8 as encoding.
Can you describe the error? Does it generate a traceback? I can test it myself shortly.
Oh sorry. Sometimes I forget that people can't read my mind.
There is no error what so ever. It only prints a double quote
Hmmm, I am able to print that symbol on my computer with pykeyboard without issue. So you say that it prints a double quote instead of the @ symbol? This might be interesting. Could you copy the output of xmodmap -pke here?
Oh sorry. Forgot to say that this is a windows problem.
It looks like perhaps you have an American keyboard but a UK layout (or vice versa?).
I have a Swedish keyboard. But that gave me some hints. Will check it out.
So I've played around a bit and I see that when I'm using swedish as keyboard layout in windows, it prints a ". But when I change to english (US), it prints a @ sign.
Note that it's the target application that needs to have this keyboard setting. The rest of the applications don't need to change theirs.
So my question is, how can I gt around this problem?
A quick fix I've made was to let the program press shift + alt at the same time, which changes the keyboard layout. Then when typing is done, it changes back
PyKeyboard relies on the VkKeyScan method of win32api to convert a character to its appropriate windows keycode. http://docs.activestate.com/activepython/2.4/pywin32/win32api__VkKeyScan_meth.html So it might seem that for certain layouts, this function is not working properly?
I know that mac uses virtual scan codes, which are identical across layouts. It seems the windows api is giving you the raw hardware code. Sent from my BlackBerry 10 smartphone. From: Paul BartonSent: dinsdag 12 november 2013 02:30To: SavinaRoja/PyUserInputReply To: SavinaRoja/PyUserInputSubject: Re: [PyUserInput] printing @ signs (#19)PyKeyboard relies on the VkKeyScan method of win32api to convert a character to its appropriate windows keycode. http://docs.activestate.com/activepython/2.4/pywin32/win32api__VkKeyScan_meth.html So it might seem that for certain layouts, this function is not working properly?
—Reply to this email directly or view it on GitHub.
I did find reference to another function that utilizes layout information http://msdn.microsoft.com/en-us/library/windows/desktop/ms646332(v=vs.85).aspx in the windows API for C++. It is my understanding that the python API is linking to the C++ one; this function is not documented in the python API.
Both of VkKeyScan and VkKeyScanEx are meant to return 2 bytes of information (a short integer); the rightmost (low-order) byte is a statemask of modifiers, and the leftmost (high-order) is a virtual keycode for the character. The documentation for win32api.keybd_event is spartan and relatively unhelpful, but it does suggest a few different avenues to pursue for testing. I may need to do some direct testing and digging through the windows api C++ source code to properly understand how to account for different keyboard layouts.