Reputation: 73
I am trying to print out text with PyAutoGUI, and I have my keyboard set to Dvorak, so whenever I print out text, it comes out with incorrect characters. For example, "Hello World!" comes out as "Jdpps <soph!".
The same thing happens when I put the string in a variable too.
Is there a way to make it print out the text literally as I typed it?
Upvotes: 3
Views: 2543
Reputation: 73
So what I ended up doing was creating a file .xkbmap-qwerty in my home directory, and then ran os.system("xmodmap ~/.xkbmap-qwerty") to load the keys, and then it didn't affect my shell when the program exited, or even while the program was running.
Here's my file:
keysym q = q Q
keysym w = w W
keysym e = e E
keysym r = r R
keysym t = t T
keysym y = y Y
keysym u = u U
keysym i = i I
keysym o = o O
keysym p = p P
keysym bracketleft = bracketleft braceleft
keysym bracketright = bracketright braceright
keysym a = a A
keysym s = s S
keysym d = d D
keysym f = f F
keysym g = g G
keysym h = h H
keysym j = j J
keysym k = k K
keysym l = l L
keysym semicolon = semicolon colon
keysym quoteright = quoteright quotedbl
keysym z = z Z
keysym x = x X
keysym c = c C
keysym v = v V
keysym b = b B
keysym n = n N
keysym m = m M
keysym comma = comma less
keysym period = period greater
keysym slash = slash question
keysym 1 = 1 exclam
keysym 2 = 2 at
keysym 3 = 3 numbersign
keysym 4 = 4 dollar
keysym 5 = 5 percent
keysym 6 = 6 asciicircum
keysym 7 = 7 ampersand
keysym 8 = 8 asterisk
keysym 9 = 9 parenleft
keysym 0 = 0 parenright
keysym minus = minus underscore
keysym equal = equal plus
Upvotes: 1