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

489 lines
18 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": [
"Уважаемый пользователь! Данный файл содержит набор преднастроенных команд для ускоренной проверки гипотез роботизации. Вся необходимая инфраструктура pyOpenRPA доступна - осуществляйте разработку максимально быстро и комфортно!\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": 1,
"metadata": {},
"outputs": [
{
"ename": "OSError",
"evalue": "Failed to read screencontact.PNG because file is missing, has improper permissions, or is an unsupported or invalid format",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mOSError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-1-df60de5fdc65>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 8\u001b[0m \u001b[1;31m# Screen: Взаимодействие с объектами экрана\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mpyOpenRPA\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mRobot\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mScreen\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 10\u001b[1;33m \u001b[0mlBoxList\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mScreen\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mImageLocateAll\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minImgPathStr\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"screencontact.PNG\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0minConfidenceFloat\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0.9\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 11\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlBoxList\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\Abs\\Archive\\scopeSrcUL\\pyOpenRPA\\Sources\\pyOpenRPA\\Robot\\Screen.py\u001b[0m in \u001b[0;36mImageLocateAll\u001b[1;34m(inImgPathStr, inIsGrayModeBool, inConfidenceFloat)\u001b[0m\n\u001b[0;32m 543\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0minConfidenceFloat\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mlLocateList\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpyautogui\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlocateAllOnScreen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mimage\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minImgPathStr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgrayscale\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minIsGrayModeBool\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 544\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mlLocateList\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpyautogui\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlocateAllOnScreen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mimage\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minImgPathStr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgrayscale\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minIsGrayModeBool\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfidence\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minConfidenceFloat\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 545\u001b[1;33m \u001b[1;32mfor\u001b[0m \u001b[0mlItem\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mlLocateList\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 546\u001b[0m \u001b[0mlResult\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlItem\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 547\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mlResult\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\Abs\\Archive\\scopeSrcUL\\pyOpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\site-packages\\pyscreeze\\__init__.py\u001b[0m in \u001b[0;36m_locateAll_opencv\u001b[1;34m(needleImage, haystackImage, grayscale, limit, region, step, confidence)\u001b[0m\n\u001b[0;32m 144\u001b[0m \u001b[0mconfidence\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfloat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mconfidence\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 145\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 146\u001b[1;33m \u001b[0mneedleImage\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_load_cv2\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mneedleImage\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgrayscale\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 147\u001b[0m \u001b[0mneedleHeight\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mneedleWidth\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mneedleImage\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 148\u001b[0m \u001b[0mhaystackImage\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_load_cv2\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhaystackImage\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgrayscale\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\Abs\\Archive\\scopeSrcUL\\pyOpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\site-packages\\pyscreeze\\__init__.py\u001b[0m in \u001b[0;36m_load_cv2\u001b[1;34m(img, grayscale)\u001b[0m\n\u001b[0;32m 111\u001b[0m raise IOError(\"Failed to read %s because file is missing, \"\n\u001b[0;32m 112\u001b[0m \u001b[1;34m\"has improper permissions, or is an \"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 113\u001b[1;33m \"unsupported or invalid format\" % img)\n\u001b[0m\u001b[0;32m 114\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mimg\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnumpy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndarray\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 115\u001b[0m \u001b[1;31m# don't try to convert an already-gray image to gray\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mOSError\u001b[0m: Failed to read screencontact.PNG because file is missing, has improper permissions, or is an unsupported or invalid format"
]
}
],
"source": [
"import sys\n",
"import os\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\Sources\"))\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\..\\\\KPI_Effect\\\\packages\"))\n",
"import time\n",
"from pyOpenRPA.Robot import Keyboard\n",
"\n",
"# Screen: Взаимодействие с объектами экрана\n",
"from pyOpenRPA.Robot import Screen\n",
"lBoxList = Screen.ImageLocateAll(inImgPathStr=\"screencontact.PNG\",inConfidenceFloat=0.9)\n",
"print(lBoxList)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#ИМПОРТ ДИРЕКТОРИИ\n",
"import sys\n",
"import os\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\..\\\\KPI_Effect\\\\packages\"))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[Box(left=500, top=244, width=29, height=29), Box(left=500, top=298, width=29, height=29), Box(left=500, top=352, width=29, height=29), Box(left=500, top=406, width=29, height=29), Box(left=500, top=460, width=29, height=29), Box(left=500, top=514, width=29, height=29), Box(left=500, top=568, width=29, height=29), Box(left=500, top=622, width=29, height=29), Box(left=500, top=676, width=29, height=29), Box(left=500, top=730, width=29, height=29), Box(left=500, top=784, width=29, height=29), Box(left=500, top=838, width=29, height=29)]\n"
]
}
],
"source": [
"lBox2List = Screen.BoxMoveTo(inBox=lBoxList,inDXInt=-50)\n",
"print(lBox2List)\n",
"Screen.BoxDraw(inBox = lBox2List)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"lPoint = Screen.BoxGetPoint(lBox2List[0])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"Screen.PointClick(lPoint)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[Box(left=489, top=243, width=46, height=32)]\n"
]
}
],
"source": [
"lBoxList = Screen.ImageLocateAll(inImgPathStr=\"sendmessage.PNG\",inConfidenceFloat=0.9)\n",
"print(lBoxList)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"Screen.PointClick(Screen.BoxGetPoint(Screen.ImageLocateAll(inImgPathStr=\"sendmessage.PNG\",inConfidenceFloat=0.9)[0]))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Box(left=169, top=193, width=409, height=687)]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Screen.ImageLocateAll(inImgPathStr=\"emptytray.PNG\",inConfidenceFloat=0.9)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import importlib"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"123\n"
]
},
{
"data": {
"text/plain": [
"<module 'pak.test' from 'C:\\\\Abs\\\\Archive\\\\scopeSrcUL\\\\pyOpenRPA\\\\Tools\\\\Jupyter-notebooks\\\\pak\\\\test.py'>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"importlib.import_module(\".test\",\"pak\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import sys"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<module 'pak' (namespace)>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sys.modules[\"pak\"]"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import datetime"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.datetime(2022, 9, 26, 20, 58, 26, 931399)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datetime.datetime.now()+datetime.timedelta(hours=3)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.timedelta(seconds=10800)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datetime.timedelta(hours=3)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'2022-09-26 17:59:17'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"g_datetime_format_str = '%Y-%m-%d %H:%M:%S'\n",
"(datetime.datetime.now()).strftime(g_datetime_format_str)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"import time"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.datetime(2022, 9, 26, 18, 1, 58, 924492)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datetime.datetime.fromtimestamp(time.time())"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"\".endswith(\"/\")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"ename": "ImportError",
"evalue": "cannot import name 'kpi_client' from '__main__' (unknown location)",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-15-2f86ae4ce68c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mkpi_client\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mImportError\u001b[0m: cannot import name 'kpi_client' from '__main__' (unknown location)"
]
}
],
"source": [
"from . import kpi_client"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"#ИМПОРТ ДИРЕКТОРИИ\n",
"import sys\n",
"import os\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\..\\\\KPI_Effect\\\\packages\"))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"import kpi_client\n",
"kpi_client.init(\"http://localhost:1024\", \"1992-04-03-0643-ru-b4ff-openrpa52zzz\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-----------START-----------\n",
"POST http://localhost:1024/orpa/api/activity-list-execute\r\n",
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n",
"Cookie: AuthToken=1992-04-03-0643-ru-b4ff-openrpa52zzz\r\n",
"Content-Length: 466\r\n",
"\r\n",
"b'[{\"Def\": \"kpi_control_panel.actions.log\", \"ArgList\": [], \"ArgDict\": {\"in_code_str\": \"asd\", \"in_group_str\": \"\\\\u041f\\\\u0440\\\\u0438\\\\u0432\\\\u0435\\\\u0442!\", \"in_manual_operation_float\": 190, \"in_auto_operation_float\": 88, \"in_start_time_float\": 123124, \"in_comment_str\": \"-\", \"in_count_int\": 1, \"in_sla_percent_float\": 1.0, \"in_dev_next_mvp_float\": 1.0, \"in_revenue_float\": 0.0, \"in_fine_float\": 0.0, \"in_reputation_str\": \"-\"}, \"ArgGSettingsStr\": null, \"ArgLoggerStr\": null}]'\n"
]
}
],
"source": [
"kpi_client.log(in_code_str=\"asd\",in_group_str=\"Привет!\",in_manual_operation_float=190, in_auto_operation_float=88, in_start_time_float=123124)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"print(\"\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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
}