好的,我终于有了一个解决方法,基于这个讨论:
https ://github.com/asweigart/pyautogui/issues/46
我在 _pyautogui_win.py 中进行了修改。并更改了“\”的键盘输入。我用这个方便的工具在我的键盘上获得了虚拟键码:http:
//www.delphiforfun.org/Programs/Utilities/KeyCodes.htm#Download
并将它们转换为十六进制代码。然后我更改了 _keyDown 函数并添加了以下内容:
if key == '\\':
ctypes.windll.user32.keybd_event(0x11, 0, 0, 0) # should be left control
ctypes.windll.user32.keybd_event(0x12, 0, 0, 0) # should be alt
ctypes.windll.user32.keybd_event(0xDB, 0, 0, 0) # should be alt ß
ctypes.windll.user32.keybd_event(0x11, 0, KEYEVENTF_KEYUP, 0)
ctypes.windll.user32.keybd_event(0x12, 0, KEYEVENTF_KEYUP, 0)
ctypes.windll.user32.keybd_event(0xDB, 0, KEYEVENTF_KEYUP, 0)
return
现在一切正常。我认为这个解决方案可以应用于任何非英语键盘布局。