我正在尝试使用pynput 中的此脚本来监视我的鼠标,但它太占用资源了。
尝试import time
添加time.sleep(1)
后on_move(x, y)
功能,但当你运行它时,你的鼠标会发疯。
这是整体代码:
import time
def on_move(x, y):
print('Pointer moved to {0}'.format((x, y)))
time.sleep(1) # <<< Tried to add it over here cuz it takes most of the process.
def on_click(x, y, button, pressed):
print('{0} at {1}'.format('Pressed' if pressed else 'Released', (x, y)))
if not pressed:
return False
def on_scroll(x, y, dx, dy):
print('Scrolled {0}'.format((x, y)))
with Listener(on_move=on_move, on_click=on_click, on_scroll=on_scroll) as listener:
listener.join()
手掌心
相关分类