1

我知道问题,但不知道如何解决它。控制器被覆盖,但我该如何改变呢?

import pynput

from pynput.keyboard import Key, Controller
from pynput.mouse import Button, Controller


keyboard = Controller()
mouse = Controller()

keyboard.press(Key.cmd_l),  keyboard.press('d')
keyboard.release(Key.cmd_l), keyboard.release('d')

mouse.move = (58, 535)
mouse.click(Button.left, 1)

with keyboard.pressed(Key.cmd_l):
    keyboard.press(Key.cmd_l)
    keyboard.release(Key.cmd_l)
    keyboard.press('d')
    keyboard.release('d')
4

1 回答 1

6

使用别名导入。

from pynput.keyboard import Key, Controller as KeyboardController
from pynput.mouse import Button, Controller as MouseController

keyboard = KeyboardController()
mouse = MouseController()
于 2019-01-21T15:30:54.743 回答