我需要使用键盘包以编程方式同时按下控制键和右箭头键。我试过keyboard.press("ctrl+right")keyboard.press("ctrl+\033[C")但两者都会导致ValueError:Traceback (most recent call last): File "C:\Users\User\anaconda3\lib\site-packages\pyHook\HookManager.py", line 351, in KeyboardSwitch return func(event) File "test2.py", line 37, in onKeyboardEvent keyboard.press("ctrl+\033[C") File "C:\Users\User\anaconda3\lib\site-packages\pynput\keyboard\_base.py", line 362, in press resolved = self._resolve(key) File "C:\Users\User\anaconda3\lib\site-packages\pynput\keyboard\_base.py", line 556, in _resolve raise ValueError(key)ValueError: ctrl+[C如何发送Ctrl-Right Arrow击键?
1 回答
冉冉说
TA贡献1877条经验 获得超1个赞
我尝试运行keyboard.press("ctrl+right")
有效(Windows),您可能会在按下后忘记释放该键。尝试keyboard.press_and_release("ctrl+right")
添加回答
举报
0/150
提交
取消