How to use the keyboard library?
How to use the keyboard to perform an activity if a certain key is pressed? In my searches, I couldn't find any example in this mold:
import keyboard
b = 0
if keyboard.press('b'): #sei que o certo não é utilizar o press, mas, o que boto no lugar?
b = 1
2
Author: Mi Tavares, 2018-11-18
1 answers
You can use the root folder of your automation with Python, for example:
pyautogui(Python2) - https://pyautogui.readthedocs.io/en/latest/keyboard.html
or
pywinauto(Python3) - https://pywinauto.readthedocs.io/en/latest/code/pywinauto.keyboard.html
import pyautogui
pyautogui.press('enter')
In python3 you could do this:
from pywinauto.keyboard import SendKeys, KeySequenceError
try:
SendKeys({ESC})
except Exception as exception:
print str(exception)
1
Author: K4L1, 2018-11-18 04:01:48