我想让函数mouse.record()运行直到按下一个键,而不是鼠标按钮。这mouse.record()是python模块中的一个函数mouse:(mouse/__init__.py)
def record(button=RIGHT, target_types=(DOWN,)):
"""
Records all mouse events until the user presses the given button. Then returns the list of events recorded. Pairs well with `play(events)`.
Note: this is a blocking function. Note: for more details on the mouse hook and events see `hook`.
"""
recorded = []
hook(recorded.append)
wait(button=button, target_types=target_types)
unhook(recorded.append)
return recorded
我一直认为我可以将mouse模块与keyboard模块合并以实现记录鼠标移动直到键盘事件的功能。有一个类似的键盘功能可能很方便:(keyboard/__init__.py)
def record(until='escape', suppress=False, trigger_on_release=False):
"""
Records all keyboard events from all keyboards until the user presses the given hotkey. Then returns the list of events recorded, of type `keyboard.KeyboardEvent`. Pairs well with `play(events)`.
Note: this is a blocking function. Note: for more details on the keyboard hook and events see `hook`.
"""
start_recording()
wait(until, suppress=suppress, trigger_on_release=trigger_on_release)
return stop_recording()
所以,总而言之,我想要实现的是一个使用 Python 模块mouse和keyboard. 这可能吗?
精慕HU
慕码人8056858
相关分类