本文整理匯總了Python中pynput.keyboard.Controller方法的典型用法代碼示例。如果您正苦於以下問題:Python keyboard.Controller方法的具體用法?Python keyboard.Controller怎麽用?Python keyboard.Controller使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pynput.keyboard
的用法示例。
在下文中一共展示了keyboard.Controller方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: enter_input
# 需要導入模塊: from pynput import keyboard [as 別名]
# 或者: from pynput.keyboard import Controller [as 別名]
def enter_input():
if PYINPUT:
keyboard = Controller()
keyboard.press(Key.enter)
keyboard.release(Key.enter)
示例2: load_instructions
# 需要導入模塊: from pynput import keyboard [as 別名]
# 或者: from pynput.keyboard import Controller [as 別名]
def load_instructions(f):
keyboard = Controller()
sleep(1)
data_file = open(f)
for line in data_file.readlines():
keyboard.type(line + "\n")
sleep(0.2)
示例3: click
# 需要導入模塊: from pynput import keyboard [as 別名]
# 或者: from pynput.keyboard import Controller [as 別名]
def click(x, y):
mouse.press(Button.left)
return
# Keyboard:
示例4: _key_change_callback
# 需要導入模塊: from pynput import keyboard [as 別名]
# 或者: from pynput.keyboard import Controller [as 別名]
def _key_change_callback(deck_id: str, _deck: StreamDeck.StreamDeck, key: int, state: bool) -> None:
if state:
keyboard = Controller()
page = get_page(deck_id)
command = get_button_command(deck_id, page, key)
if command:
Popen(command.split(" "))
keys = get_button_keys(deck_id, page, key)
if keys:
keys = keys.strip().replace(" ", "")
for section in keys.split(","):
for key_name in section.split("+"):
keyboard.press(getattr(Key, key_name.lower(), key_name))
for key_name in section.split("+"):
keyboard.release(getattr(Key, key_name.lower(), key_name))
write = get_button_write(deck_id, page, key)
if write:
keyboard.type(write)
brightness_change = get_button_change_brightness(deck_id, page, key)
if brightness_change:
change_brightness(deck_id, brightness_change)
switch_page = get_button_switch_page(deck_id, page, key)
if switch_page:
set_page(deck_id, switch_page - 1)
示例5: __init__
# 需要導入模塊: from pynput import keyboard [as 別名]
# 或者: from pynput.keyboard import Controller [as 別名]
def __init__(self, addr=DEFAULT_ADDR):
self.reactor = None
self.addr = addr
self.running = False
self.root = None
self.keyboard = Controller()
示例6: __init__
# 需要導入模塊: from pynput import keyboard [as 別名]
# 或者: from pynput.keyboard import Controller [as 別名]
def __init__(self):
self.keyboard = Controller()