You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Utils/Jupyter-notebooks/Keyboard.ipynb

571 lines
14 KiB

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Тест функций pyOpenRPA.Robot.Keyboard"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import os\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\Sources\"))\n",
"import time\n",
"from pyOpenRPA.Robot import Keyboard"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"done\n"
]
}
],
"source": [
"\n",
"time.sleep(3)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_CTRL_LEFT,Keyboard.KEY_ENG_A)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_CTRL_LEFT,Keyboard.KEY_ENG_C)\n",
"print(\"done\")"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"time.sleep(2)\n",
"Keyboard.press(Keyboard.KEY_HOT_SHIFT_LEFT)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"time.sleep(2)\n",
"Keyboard.HotkeyCtrlA_CtrlC()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"time.sleep(2)\n",
"Keyboard.send(Keyboard.KEY_HOT_CONTEXT_MENU)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"Keyboard.wait(Keyboard.KEY_ENG_B)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"done\n"
]
}
],
"source": [
"\n",
"time.sleep(1)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_CTRL_LEFT,Keyboard.KEY_ENG_A)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_CTRL_LEFT,Keyboard.KEY_ENG_C)\n",
"print(\"done\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"time.sleep(3)\n",
"\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.Write(\"cmd\")\n",
"Keyboard.Send(Keyboard.KEY_HOT_ENTER, inWaitAfterSecFloat=0.6)\n",
"Keyboard.Write(\"echo %time%\")\n",
"Keyboard.Send(Keyboard.KEY_HOT_ENTER)\n",
"Keyboard.Write(\"Привет мир!\")\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_CTRL_LEFT, Keyboard.KEY_ENG_A, inWaitAfterSecFloat=0.6)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_CTRL_LEFT, Keyboard.KEY_ENG_C, inWaitAfterSecFloat=0.6)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"57435"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Keyboard.KEY_HOT_WIN_LEFT"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"29"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Keyboard.KEY_HOT_CTRL_LEFT"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(19,)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Keyboard.key_to_scan_codes(\"win\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"Keyboard.HotkeyCombination(57435,19)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)\n",
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['HotkeyCombination',\n",
" 'HotkeyCtrlA_CtrlC',\n",
" 'KEY_DOWN',\n",
" 'KEY_ENG_A',\n",
" 'KEY_ENG_B',\n",
" 'KEY_ENG_C',\n",
" 'KEY_ENG_D',\n",
" 'KEY_ENG_E',\n",
" 'KEY_ENG_F',\n",
" 'KEY_ENG_G',\n",
" 'KEY_ENG_H',\n",
" 'KEY_ENG_I',\n",
" 'KEY_ENG_J',\n",
" 'KEY_ENG_K',\n",
" 'KEY_ENG_L',\n",
" 'KEY_ENG_M',\n",
" 'KEY_ENG_N',\n",
" 'KEY_ENG_O',\n",
" 'KEY_ENG_P',\n",
" 'KEY_ENG_Q',\n",
" 'KEY_ENG_R',\n",
" 'KEY_ENG_S',\n",
" 'KEY_ENG_T',\n",
" 'KEY_ENG_U',\n",
" 'KEY_ENG_V',\n",
" 'KEY_ENG_W',\n",
" 'KEY_ENG_X',\n",
" 'KEY_ENG_Y',\n",
" 'KEY_ENG_Z',\n",
" 'KEY_HOT_0',\n",
" 'KEY_HOT_1',\n",
" 'KEY_HOT_2',\n",
" 'KEY_HOT_3',\n",
" 'KEY_HOT_4',\n",
" 'KEY_HOT_5',\n",
" 'KEY_HOT_6',\n",
" 'KEY_HOT_7',\n",
" 'KEY_HOT_8',\n",
" 'KEY_HOT_9',\n",
" 'KEY_HOT_ALT_LEFT',\n",
" 'KEY_HOT_ALT_RIGHT',\n",
" 'KEY_HOT_APOSTROPHE',\n",
" 'KEY_HOT_BACKSPACE',\n",
" 'KEY_HOT_CAPS_LOCK',\n",
" 'KEY_HOT_CLEAR',\n",
" 'KEY_HOT_COLON',\n",
" 'KEY_HOT_CONTEXT_MENU',\n",
" 'KEY_HOT_CTRL_LEFT',\n",
" 'KEY_HOT_CTRL_RIGHT',\n",
" 'KEY_HOT_DELETE',\n",
" 'KEY_HOT_DOWN',\n",
" 'KEY_HOT_END',\n",
" 'KEY_HOT_ENTER',\n",
" 'KEY_HOT_ESC',\n",
" 'KEY_HOT_F1',\n",
" 'KEY_HOT_F10',\n",
" 'KEY_HOT_F11',\n",
" 'KEY_HOT_F12',\n",
" 'KEY_HOT_F13',\n",
" 'KEY_HOT_F14',\n",
" 'KEY_HOT_F15',\n",
" 'KEY_HOT_F16',\n",
" 'KEY_HOT_F17',\n",
" 'KEY_HOT_F18',\n",
" 'KEY_HOT_F19',\n",
" 'KEY_HOT_F2',\n",
" 'KEY_HOT_F20',\n",
" 'KEY_HOT_F21',\n",
" 'KEY_HOT_F22',\n",
" 'KEY_HOT_F23',\n",
" 'KEY_HOT_F24',\n",
" 'KEY_HOT_F3',\n",
" 'KEY_HOT_F4',\n",
" 'KEY_HOT_F5',\n",
" 'KEY_HOT_F6',\n",
" 'KEY_HOT_F7',\n",
" 'KEY_HOT_F8',\n",
" 'KEY_HOT_F9',\n",
" 'KEY_HOT_GREATER_THAN',\n",
" 'KEY_HOT_HOME',\n",
" 'KEY_HOT_INSERT',\n",
" 'KEY_HOT_LEFT',\n",
" 'KEY_HOT_LESS_THAN',\n",
" 'KEY_HOT_MINUS',\n",
" 'KEY_HOT_NUMPAD_0',\n",
" 'KEY_HOT_NUMPAD_1',\n",
" 'KEY_HOT_NUMPAD_2',\n",
" 'KEY_HOT_NUMPAD_3',\n",
" 'KEY_HOT_NUMPAD_4',\n",
" 'KEY_HOT_NUMPAD_5',\n",
" 'KEY_HOT_NUMPAD_6',\n",
" 'KEY_HOT_NUMPAD_7',\n",
" 'KEY_HOT_NUMPAD_8',\n",
" 'KEY_HOT_NUMPAD_9',\n",
" 'KEY_HOT_NUMPAD_ASTERISK',\n",
" 'KEY_HOT_NUMPAD_DELETE',\n",
" 'KEY_HOT_NUMPAD_ENTER',\n",
" 'KEY_HOT_NUMPAD_MINUS',\n",
" 'KEY_HOT_NUMPAD_PLUS',\n",
" 'KEY_HOT_NUMPAD_SOLIDUS',\n",
" 'KEY_HOT_NUM_LOCK',\n",
" 'KEY_HOT_PAGE_DOWN',\n",
" 'KEY_HOT_PAGE_UP',\n",
" 'KEY_HOT_PLUS',\n",
" 'KEY_HOT_PRINT_SCREEN',\n",
" 'KEY_HOT_RIGHT',\n",
" 'KEY_HOT_SCROLL_LOCK',\n",
" 'KEY_HOT_SHIFT_LEFT',\n",
" 'KEY_HOT_SHIFT_RIGHT',\n",
" 'KEY_HOT_SOLIDUS',\n",
" 'KEY_HOT_SPACE',\n",
" 'KEY_HOT_SQUARE_BRACKET_LEFT',\n",
" 'KEY_HOT_SQUARE_BRACKET_RIGHT',\n",
" 'KEY_HOT_TAB',\n",
" 'KEY_HOT_TILDE',\n",
" 'KEY_HOT_UP',\n",
" 'KEY_HOT_VERTICAL_LINE',\n",
" 'KEY_HOT_WIN_LEFT',\n",
" 'KEY_HOT_WIN_RIGHT',\n",
" 'KEY_RUS_Ё',\n",
" 'KEY_RUS_А',\n",
" 'KEY_RUS_Б',\n",
" 'KEY_RUS_В',\n",
" 'KEY_RUS_Г',\n",
" 'KEY_RUS_Д',\n",
" 'KEY_RUS_Е',\n",
" 'KEY_RUS_Ж',\n",
" 'KEY_RUS_З',\n",
" 'KEY_RUS_И',\n",
" 'KEY_RUS_Й',\n",
" 'KEY_RUS_К',\n",
" 'KEY_RUS_Л',\n",
" 'KEY_RUS_М',\n",
" 'KEY_RUS_Н',\n",
" 'KEY_RUS_О',\n",
" 'KEY_RUS_П',\n",
" 'KEY_RUS_Р',\n",
" 'KEY_RUS_С',\n",
" 'KEY_RUS_Т',\n",
" 'KEY_RUS_У',\n",
" 'KEY_RUS_Ф',\n",
" 'KEY_RUS_Х',\n",
" 'KEY_RUS_Ц',\n",
" 'KEY_RUS_Ч',\n",
" 'KEY_RUS_Ш',\n",
" 'KEY_RUS_Щ',\n",
" 'KEY_RUS_Ъ',\n",
" 'KEY_RUS_Ы',\n",
" 'KEY_RUS_Ь',\n",
" 'KEY_RUS_Э',\n",
" 'KEY_RUS_Ю',\n",
" 'KEY_RUS_Я',\n",
" 'KEY_UP',\n",
" 'KeyboardEvent',\n",
" 'Send',\n",
" 'Wait',\n",
" 'Write',\n",
" '__builtins__',\n",
" '__cached__',\n",
" '__doc__',\n",
" '__file__',\n",
" '__loader__',\n",
" '__name__',\n",
" '__package__',\n",
" '__spec__',\n",
" 'add_abbreviation',\n",
" 'add_hotkey',\n",
" 'add_word_listener',\n",
" 'all_modifiers',\n",
" 'block_key',\n",
" 'call_later',\n",
" 'clear_all_hotkeys',\n",
" 'clear_hotkey',\n",
" 'get_hotkey_name',\n",
" 'get_typed_strings',\n",
" 'hook',\n",
" 'hook_key',\n",
" 'is_modifier',\n",
" 'is_pressed',\n",
" 'key_to_scan_codes',\n",
" 'normalize_name',\n",
" 'on_press',\n",
" 'on_press_key',\n",
" 'on_release',\n",
" 'on_release_key',\n",
" 'parse_hotkey',\n",
" 'parse_hotkey_combinations',\n",
" 'play',\n",
" 'press',\n",
" 'press_and_release',\n",
" 'read_event',\n",
" 'read_hotkey',\n",
" 'read_key',\n",
" 'record',\n",
" 'register_abbreviation',\n",
" 'register_hotkey',\n",
" 'register_word_listener',\n",
" 'release',\n",
" 'remap_hotkey',\n",
" 'remap_key',\n",
" 'remove_abbreviation',\n",
" 'remove_all_hotkeys',\n",
" 'remove_hotkey',\n",
" 'remove_word_listener',\n",
" 'replay',\n",
" 'restore_modifiers',\n",
" 'restore_state',\n",
" 'send',\n",
" 'sided_modifiers',\n",
" 'start_recording',\n",
" 'stash_state',\n",
" 'stop_recording',\n",
" 'time',\n",
" 'unblock_key',\n",
" 'unhook',\n",
" 'unhook_all',\n",
" 'unhook_all_hotkeys',\n",
" 'unhook_key',\n",
" 'unregister_all_hotkeys',\n",
" 'unregister_hotkey',\n",
" 'unremap_hotkey',\n",
" 'unremap_key',\n",
" 'wait',\n",
" 'write']"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dir(Keyboard)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"Keyboard.HotkeyCombination(Keyboard.KEY_HOT_WIN_LEFT,Keyboard.KEY_ENG_R)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"time.sleep(3)\n",
"Keyboard.is_pressed(Keyboard.KEY_HOT_CTRL_LEFT)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"TT=9\n",
"def k(hh=TT):\n",
" print(hh)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"9\n"
]
}
],
"source": [
"k()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}