Нажмите горячую клавишу, например, shift a и одновременно введите строку и нажмите ввод.Это должно быть сделано в методе on_press
?
Код:
from pynput import keyboard
from pynput.mouse import Button, Controller
COMBINATIONS = [
{keyboard.Key.shift, keyboard.KeyCode(char='a')}
]
current = set()
def execute():
mouse = Controller()
mouse.position = (550, 80)
mouse.click(Button.left, 2)
# keyboard = Controller()
keyboard.type('google.com')
# keyboard.press(keyboard.Key.enter)
# keyboard.release(keyboard.Key.enter)
def on_press(key):
if any([key in COMBO for COMBO in COMBINATIONS]):
current.add(key)
if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS):
execute()
def on_release(key):
if any([key in COMBO for COMBO in COMBINATIONS]):
current.remove(key)
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
Я получаю следующую ошибку:
AttributeError: module 'pynput.keyboard'не имеет атрибута' тип '