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/Tools/Jupyter-notebooks/Quickstart/Robot.ipynb

259 lines
7.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Робот: быстрый запуск (quickstart) "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Уважаемый пользователь! \n",
"\n",
"Данный файл содержит набор преднастроенных команд для ускоренной прототипирования роботов. Вся необходимая инфраструктура pyOpenRPA доступна из одного файла - осуществляйте разработку максимально быстро и комфортно!\n",
"\n",
"Документация pyOpenRPA доступна по адресу: https://pyopenrpa.ru/wiki/guide/index\n",
"\n",
"По всем вопросам обращайтесь к нам.\n",
"\n",
"**Центр поддержки клиентов pyOpenRPA:**\n",
"- ⚡ Телеграм: @pyOpenRPA_Support \n",
"- ⚡ Почта: Support@pyOpenRPA.ru \n",
"- ⚡ Телефон: +7 995 233 45 31 \n",
"\n",
"❤️ pyOpenRPA - роботы помогут!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Шаг 1 - Импорт модулей pyOpenRPA"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import os\n",
"import time\n",
"\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\..\\\\Sources\")) # FOR WINDOWS\n",
"#sys.path.insert(0, os.path.abspath(\"../../../Sources\")) # FOR LINUX"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Шаг 2 - Пишем робота"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# Здесь будет код вашего робота...\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Примеры использования модулей"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# UIDesktop: Взаимодействие с объектами локального приложения\n",
"from pyOpenRPA.Robot import UIDesktop\n",
"\n",
"# 1С: UIO Селектор выбора базы\n",
"lDemoBaseUIOSelector = [{\"title\":\"Запуск 1С:Предприятия\",\"class_name\":\"V8TopLevelFrameTaxiStarter\",\"backend\":\"uia\"},{\"title\":\"DEMO\", \"depth_start\": 5, \"depth_end\": 5}] \n",
"lDemoBaseUIO = UIDesktop.UIOSelector_Get_UIO(lDemoBaseUIOSelector) #Получить 1-й UIO объект, которые удовлетворяет требованиям UIO селектора. В нашем примере либо None, либо UIO объект\n",
"\n",
"lDemoBaseUIO.click_input()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# UIWeb: Взаимодействие с объектами web страницы\n",
"from pyOpenRPA.Robot import UIWeb\n",
"\n",
"UIWeb.BrowserChromeStart()\n",
"UIWeb.PageOpen(\"https://mail.ru\")\n",
"UIWeb.PageJSExecute(\"alert(arguments[0]);\", \"hello world!\")\n",
"lUIOSelectorStr = \"#grid > div.grid-middle > div.grid__main-col.svelte-2y66pa > div.grid_newscol.grid_newscol__more-pulse.svelte-1yvqfic > div.grid__ccol.svelte-1yvqfic > ul > li:nth-child(5) > div > a\"\n",
"lUIOSelectorStr = \"//*[@id=\\\"grid\\\"]/div[2]/div[2]/div[3]/div[1]/ul/li[5]/div/a\"\n",
"UIWeb.UIOSelectorHighlight(lUIOSelectorStr)\n",
"lUIO=UIWeb.UIOSelectorList(lUIOSelectorStr)[0]\n",
"\n",
"UIWeb.BrowserClose()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Keyboard: Взаимодействие с клавиатурой\n",
"from pyOpenRPA.Robot import Keyboard\n",
"\n",
"time.sleep(2)\n",
"Keyboard.Write(\"Привет мир! / Hello world!\")\n",
"\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",
"\n",
"Keyboard.Send(Keyboard.KEY_ENG_E)\n",
"Keyboard.Send(Keyboard.KEY_RUS_Ш)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# Clipboard: Взаимодействие с буфером обмена\n",
"from pyOpenRPA.Robot import Clipboard\n",
"\n",
"Clipboard.Set(inTextStr=\"Hello!\")\n",
"lClipStr = Clipboard.Get()\n",
"print(lClipStr)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# Screen: Взаимодействие с объектами экрана\n",
"from pyOpenRPA.Robot import Screen\n",
"\n",
"lBoxList = Screen.ImageLocateAll(inImgPathStr=\"ScreenItem.png\",inConfidenceFloat=0.9)\n",
"print(lBoxList)\n",
"lBox2List = Screen.BoxMoveTo(inBox=lBoxList,inDXInt=-50)\n",
"print(lBox2List)\n",
"Screen.BoxDraw(inBox = lBox2List)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Mouse: Взаимодействие с мышью\n",
"from pyOpenRPA.Robot import Mouse\n",
"\n",
"Mouse.Click(10,15) #Выполнить нажатие левой клавиши мыши на экране по координатам: X(гор) 100px, Y(вер) 150px.\n",
"Mouse.Down() #Опустить левую клавишу мыши\n",
"Mouse.ClickDouble(100,150) #Выполнить двойное нажатие левой клавиши мыши на экране по координатам: X(гор) 100px, Y(вер) 150px."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Audio: Взаимодействие с аудиоустройствами (захват звка микрофона или приложения)\n",
"from pyOpenRPA.Robot import Audio\n",
"\n",
"Audio.DeviceListGet()\n",
"\n",
"lRec = Audio.Recorder(inDeviceInt = Audio.DeviceMicrophoneIndex()) #Захват микрофона\n",
"lRec.CaptureStart(inFileNameStr = \"out\", inFileFormatStr = \"mp3\", inDurationSecFloat = None, inChunkSecFloat = 15.0)\n",
"lRec.CaptureStop()\n",
"\n",
"lRec = Audio.Recorder() # Звахват звуков приложений\n",
"lRec.CaptureStart(inFileNameStr = \"out\", inFileFormatStr = \"mp3\", inDurationSecFloat = None, inChunkSecFloat = 5.0)\n",
"lRec.CaptureStop()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.2"
},
"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
}