|
|
.. _module.robot.keyboard:
|
|
|
|
|
|
####################################
|
|
|
4. Keyboard
|
|
|
####################################
|
|
|
|
|
|
**************************************************
|
|
|
Примеры использования
|
|
|
**************************************************
|
|
|
|
|
|
Here you can find the functions description for interaction with desktop GUI applications
|
|
|
|
|
|
How to use both x32 and x64 python processes (it can be helpfully, if another app GUI is on another bitness than your app)
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
# Keyboard: Взаимодействие с клавиатурой
|
|
|
from pyOpenRPA.Robot import Keyboard
|
|
|
from pyOpenRPA.Robot import Clipboard
|
|
|
Keyboard.send("win+r")
|
|
|
time.sleep(0.3)
|
|
|
Keyboard.write("cmd")
|
|
|
time.sleep(0.3)
|
|
|
Keyboard.send("enter")
|
|
|
time.sleep(0.6)
|
|
|
Keyboard.write("echo %time%")
|
|
|
time.sleep(0.3)
|
|
|
Keyboard.send("enter")
|
|
|
time.sleep(0.3)
|
|
|
Keyboard.send("ctrl+a")
|
|
|
time.sleep(0.6)
|
|
|
Clipboard.ClipboardSet("")
|
|
|
Keyboard.send("ctrl+c")
|
|
|
time.sleep(0.6)
|
|
|
lTextRaw = Clipboard.ClipboardGet()
|
|
|
lTimeStr = lTextRaw.split("\n")[-3]
|
|
|
|
|
|
**************************************************
|
|
|
Описание методов
|
|
|
**************************************************
|
|
|
|
|
|
|
|
|
.. automodule:: pyOpenRPA.Robot.Keyboard
|
|
|
:members:
|
|
|
:autosummary:
|
|
|
|
|
|
|
|
|
**************************************************
|
|
|
Коды клавиш
|
|
|
**************************************************
|
|
|
Ниже представлены коды горячих клавиш, а также символов русской и английской раскладки.
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
# ШЕСТНАДЦАТИРИЧНЫЙ СКАН-КОД В РУССКОЙ РАСКЛАДКЕ (НЕЗАВИСИМО ОТ ВЫБРАННОГО ЯЗЫКА НА КЛАВИАТУРЕ)
|
|
|
# ОТОБРАЖЕНИЕ СКАН КОДОВ НА КЛАВИАТУРЕ https://snipp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EFT = 0x2A
|
|
|
KEY_HOT_SHIFT_RIGHT = 0x36
|
|
|
KEY_HOT_CTRL_LEFT = 0x1D
|
|
|
KEY_HOT_CTRL_RIGHT = 0x11D
|
|
|
KEY_HOT_ALT_LEFT = 0x38
|
|
|
KEY_HOT_ALT_RIGHT = 0x138
|
|
|
KEY_HOT_WIN_LEFT = 0x5B
|
|
|
KEY_HOT_WIN_RIGHT = 0x5C
|
|
|
KEY_HOT_CAPS_LOCK = 0x3A
|
|
|
KEY_HOT_NUM_LOCK = 0x45
|
|
|
KEY_HOT_SCROLL_LOCK = 0x46
|
|
|
KEY_HOT_END = 0x4F
|
|
|
KEY_HOT_HOME = 0x47
|
|
|
KEY_HOT_SPACE = 0x39
|
|
|
KEY_HOT_PAGE_UP = 0x49
|
|
|
KEY_HOT_PAGE_DOWN = 0x51
|
|
|
KEY_HOT_CLEAR = 0x4C
|
|
|
KEY_HOT_LEFT = 0x4B
|
|
|
KEY_HOT_UP = 0x48
|
|
|
KEY_HOT_RIGHT = 0x4D
|
|
|
KEY_HOT_DOWN = 0x50
|
|
|
KEY_HOT_PRINT_SCREEN = 0x137
|
|
|
KEY_HOT_INSERT = 0x52
|
|
|
KEY_HOT_DELETE = 0x53
|
|
|
|
|
|
KEY_HOT_0 = 0xB
|
|
|
KEY_HOT_1 = 0x2
|
|
|
KEY_HOT_2 = 0x3
|
|
|
KEY_HOT_3 = 0x4
|
|
|
KEY_HOT_4 = 0x5
|
|
|
KEY_HOT_5 = 0x6
|
|
|
KEY_HOT_6 = 0x7
|
|
|
KEY_HOT_7 = 0x8
|
|
|
KEY_HOT_8 = 0x9
|
|
|
KEY_HOT_9 = 0xA
|
|
|
|
|
|
**************************************************
|
|
|
Дополнительная функциональность
|
|
|
**************************************************
|
|
|
Дополнительно модуль содержит функции вспомогательной библиотеки. Ознакомиться с описанием можно `Здесь <https://github.com/boppreh/keyboard#api>`_
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
# Пример использования функции send
|
|
|
from pyOpenRPA.Robot import Keyboard
|
|
|
Keyboard.send(57)
|