I have a folder, which I'm trying to input in Python as a string, for example folder = r'C:\Users\Desktop'
or folder = 'C:\\Users\\Desktop'
I'm then using pyautogui.typewrite(folder)
, but when I do so the directory name is pasted as C'<Users<Desktop
Do you know what is causing that and how can I solve this issue?
Thank you!
Asked
Active
Viewed 102 times
-1

Gustavo
- 1
- 3
-
2What's your keyboard layout? – SuperStormer Oct 23 '21 at 18:11
-
Also see https://stackoverflow.com/questions/33151865/input-unicode-string-with-pyautogui – SuperStormer Oct 23 '21 at 18:19
-
I'm always changing between languages (German/English/Portuguese). Usually when I'm coding I set it in german, which is my original keyboard configuration. I'll have a look at this link you shared. – Gustavo Oct 23 '21 at 18:23
1 Answers
0
[Solution]
Combining both inputs from "SuperStormer" (thanks a lot!!) along with some additional research and adaptation I manage to solve the issue by:
- Change the keyboard to English - looks like pyautogui emulates the typing of the keyboard, and it doesn't support any language other than english - this almost solved my issue, it solved the backslashes, but then the ":" started to become a "?", like
'C?\Users\Desktop'
- Use pyperclip to paste string directly from keyboard - I did some simulations and that would have worked, except that I already had something on my clipboard that had to be used in a later step, and as I couldn't find a way to reference more than two clipboards at a time that didn't work right away, but after some workarounds based on that function I finally got to the solution

Gustavo
- 1
- 3