From b5996fad45506e06b2eaa483494e0d521e927f0a Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Mon, 10 Oct 2022 21:13:20 +0300 Subject: [PATCH] final fixes for 1.3.1 --- Orchestrator/Demo/HELLO/html_jinja2.xhtml | 6 +- Orchestrator/config.py | 1 + .../GuideSphinx/Orchestrator/04_HowToUse.rst | 6 +- Sources/GuideSphinx/Robot/08_audio.rst | 4 + Sources/GuideSphinx/Robot/09_HowToUse.rst | 2 + Sources/GuideSphinx/Studio/02_HowToUse.rst | 2 +- Sources/pyOpenRPA/Orchestrator/ServerBC.py | 10 +- .../Orchestrator/__Orchestrator__.py | 9 +- .../Jupyter-notebooks/Quickstart/Robot.ipynb | 430 ++++-------------- .../Quickstart/ScreenItem.png | Bin 0 -> 999 bytes 10 files changed, 128 insertions(+), 342 deletions(-) create mode 100644 Tools/Jupyter-notebooks/Quickstart/ScreenItem.png diff --git a/Orchestrator/Demo/HELLO/html_jinja2.xhtml b/Orchestrator/Demo/HELLO/html_jinja2.xhtml index 4e9f322b..0ab4fdfc 100644 --- a/Orchestrator/Demo/HELLO/html_jinja2.xhtml +++ b/Orchestrator/Demo/HELLO/html_jinja2.xhtml @@ -3,7 +3,11 @@
-

Добро пожаловать {{UserInfoDict["UserNameUpperStr"]}}!

+

Добро пожаловать + {% if UserInfoDict["UserNameUpperStr"] %} + {{UserInfoDict["UserNameUpperStr"]}} + {% endif %} + !

diff --git a/Orchestrator/config.py b/Orchestrator/config.py index d6d86a48..67651dea 100755 --- a/Orchestrator/config.py +++ b/Orchestrator/config.py @@ -44,6 +44,7 @@ else: Orchestrator.OrchestratorLoggerGet().setLevel(logging.INFO) # TEST Add User ND - Add Login ND to superuser of the Orchestrator lUACClientDict = SettingsTemplate.__UACClientAdminCreate__() + gSettings["ServerDict"]["AccessUsers"]["FlagCredentialsAsk"]=False Orchestrator.UACUpdate(inGSettings=gSettings, inADLoginStr="ND", inADStr="", inADIsDefaultBool=True, inURLList=[], inRoleHierarchyAllowedDict=lUACClientDict) Orchestrator.UACUpdate(inGSettings=gSettings, inADLoginStr="rpa00", inADStr="", inADIsDefaultBool=True, inURLList=[], inRoleHierarchyAllowedDict=lUACClientDict) # TEST Add User IMaslov - Add Login IMaslov to superuser of the Orchestrator diff --git a/Sources/GuideSphinx/Orchestrator/04_HowToUse.rst b/Sources/GuideSphinx/Orchestrator/04_HowToUse.rst index c92f98b6..55d371a5 100755 --- a/Sources/GuideSphinx/Orchestrator/04_HowToUse.rst +++ b/Sources/GuideSphinx/Orchestrator/04_HowToUse.rst @@ -10,7 +10,7 @@ **Для этого достаточно (выбрать одно):** -- запустить .cmd файл, расположенный в папке pyOpenRPA по адресу: Orchestrator\pyOpenRPA.Orchestrator_x64.cmd +- запустить демо-стэнд: запустить .cmd файл, расположенный в папке pyOpenRPA по адресу: Orchestrator\start.cmd (для Windows) и start.sh (для Linux). Далее перейти в браузер по адресу: http://localhost:1024 - в свой .py скрипт добавить следующий код (см. ниже) .. code-block:: python @@ -23,12 +23,12 @@ ****************************** -Параметры настройки +Конфигурационный файл config.py ****************************** Также вы можете выполнить более тонкую настройку параметров Оркестратора. Ниже пример такой настройки: -.. include:: ../../../Orchestrator/OrchestratorSettings.py +.. include:: ../../../Orchestrator/config.py :literal: diff --git a/Sources/GuideSphinx/Robot/08_audio.rst b/Sources/GuideSphinx/Robot/08_audio.rst index 95a5f177..9ea04990 100644 --- a/Sources/GuideSphinx/Robot/08_audio.rst +++ b/Sources/GuideSphinx/Robot/08_audio.rst @@ -6,9 +6,12 @@ !ВНИМАНИЕ! ДЛЯ КОРРЕКТНОЙ РАБОТЫ МОДУЛЯ ТРЕБУЕТСЯ КОМПОНЕНТ ffmpeg.exe (Для Windows x64 можно найти в pyOpenRPA\Resources\WAudio). На него должен указывать один из путей в переменной окружения PATH. Или ffmpeg.exe должен быть расположен в рабочей директории (working directory) +!ВНИМАНИЕ! ДЛЯ ВИРТУАЛЬНОЙ МАШИНЫ МОЖЕТ ПОТРЕБОВАТЬСЯ КОМПОНЕНТ ВИРТУАЛЬНОГО АУДИОДРАЙВЕРА (Для Windows x64 можно найти в pyOpenRPA\Resources\WAudio\VBCABLE_Driver_Pack43.zip) + ************************ Общее ************************ + Дорогие коллеги! Мы знаем, что с pyOpenRPA вы сможете существенно улучшить качество вашего бизнеса. Платформа роботизации pyOpenRPA - это разработка, которая дает возможность делать виртуальных сотрудников (программных роботов RPA) выгодными, начиная от эффекта всего в **10 тыс. руб.** И управлять ими будете только Вы! @@ -20,6 +23,7 @@ pyOpenRPA - роботы помогут! ************************ Класс Recorder ************************ + Экземпляр класса pyOpenRPA.Robot.Audio.Recorder, который обеспечивает захват звука (с микрофона или из приложений) и сохраняет в виде аудиофайла (множества аудиофайлов) diff --git a/Sources/GuideSphinx/Robot/09_HowToUse.rst b/Sources/GuideSphinx/Robot/09_HowToUse.rst index f314abe9..231d207d 100644 --- a/Sources/GuideSphinx/Robot/09_HowToUse.rst +++ b/Sources/GuideSphinx/Robot/09_HowToUse.rst @@ -18,6 +18,8 @@ Быстрая инфраструктура для прототипирования робота готова! +В файле Robot.ipynb содержится вся необходимая информация, которая позволит решить любую поставленную задачу. + ************************************************** Как запустить скрипт робота? ************************************************** diff --git a/Sources/GuideSphinx/Studio/02_HowToUse.rst b/Sources/GuideSphinx/Studio/02_HowToUse.rst index fb0c6678..39026dcf 100755 --- a/Sources/GuideSphinx/Studio/02_HowToUse.rst +++ b/Sources/GuideSphinx/Studio/02_HowToUse.rst @@ -22,7 +22,7 @@ Как запустить? ************************ -- Запустить файл Studio\pyOpenRPA.Studio_x64.cmd +- Запустить файл Studio\start.cmd - Ожидать текст в окне консоли: "running server". Браузер, установленный по умолчанию откроется автоматически - **!ВНИМАНИЕ!** Студия поддерживает все версии браузеров, кроме Internet Explorer. diff --git a/Sources/pyOpenRPA/Orchestrator/ServerBC.py b/Sources/pyOpenRPA/Orchestrator/ServerBC.py index 2983c13c..ff444f18 100644 --- a/Sources/pyOpenRPA/Orchestrator/ServerBC.py +++ b/Sources/pyOpenRPA/Orchestrator/ServerBC.py @@ -192,10 +192,12 @@ class HTTPRequestOld(): # Def to get hierarchy of the current user roles # if return {} - all is available def UserRoleHierarchyGet(self): - lDomainUpperStr = self.OpenRPA["Domain"].upper() - lUserUpperStr = self.OpenRPA["User"].upper() - return __Orchestrator__.GSettingsGet().get("ServerDict", {}).get("AccessUsers", {}).get("RuleDomainUserDict", {}).get((lDomainUpperStr, lUserUpperStr), {}).get("RoleHierarchyAllowedDict", {}) - + try: + lDomainUpperStr = self.OpenRPA["Domain"].upper() + lUserUpperStr = self.OpenRPA["User"].upper() + return __Orchestrator__.GSettingsGet().get("ServerDict", {}).get("AccessUsers", {}).get("RuleDomainUserDict", {}).get((lDomainUpperStr, lUserUpperStr), {}).get("RoleHierarchyAllowedDict", {}) + except Exception as e: + return {} #Tech def #return {"headers":[],"body":"","statuscode":111} def URLItemCheckDo(self, inURLItem, inMethod, inOnlyFlagUACBool = False): diff --git a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py index e62a3b75..a263bde3 100755 --- a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py +++ b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py @@ -1203,9 +1203,12 @@ def WebUserInfoGet(inRequest=None): :return: Сведения в формате {"DomainUpperStr": "PYOPENRPA", "UserNameUpperStr": "IVAN.MASLOV"} """ if inRequest is None: inRequest = WebRequestGet() - lDomainUpperStr = inRequest.OpenRPA["Domain"].upper() - lUserUpperStr = inRequest.OpenRPA["User"].upper() - return {"DomainUpperStr": lDomainUpperStr, "UserNameUpperStr": lUserUpperStr} + try: + lDomainUpperStr = inRequest.OpenRPA["Domain"].upper() + lUserUpperStr = inRequest.OpenRPA["User"].upper() + return {"DomainUpperStr": lDomainUpperStr, "UserNameUpperStr": lUserUpperStr} + except Exception as e: + return {"DomainUpperStr": None, "UserNameUpperStr": None} def WebUserIsSuperToken(inAuthTokenStr: str=None): """L+,W+: [ИЗМЕНЕНИЕ В 1.3.1] Проверить, авторизован ли HTTP запрос с помощью супер токена (токен, который не истекает). diff --git a/Tools/Jupyter-notebooks/Quickstart/Robot.ipynb b/Tools/Jupyter-notebooks/Quickstart/Robot.ipynb index bba98acc..603417d2 100644 --- a/Tools/Jupyter-notebooks/Quickstart/Robot.ipynb +++ b/Tools/Jupyter-notebooks/Quickstart/Robot.ipynb @@ -11,7 +11,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Уважаемый пользователь! Данный файл содержит набор преднастроенных команд для ускоренной проверки гипотез роботизации. Вся необходимая инфраструктура pyOpenRPA доступна - осуществляйте разработку максимально быстро и комфортно!\n", + "Уважаемый пользователь! \n", + "\n", + "Данный файл содержит набор преднастроенных команд для ускоренной прототипирования роботов. Вся необходимая инфраструктура pyOpenRPA доступна из одного файла - осуществляйте разработку максимально быстро и комфортно!\n", + "\n", + "Документация pyOpenRPA доступна по адресу: https://pyopenrpa.ru/wiki/guide/index\n", + "\n", + "По всем вопросам обращайтесь к нам.\n", "\n", "**Центр поддержки клиентов pyOpenRPA:**\n", "- ⚡ Телеграм: @pyOpenRPA_Support \n", @@ -25,272 +31,127 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Шаг 1 - Загрузка последней версии pyOpenRPA" + "## Шаг 1 - Импорт модулей pyOpenRPA" ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 8, "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\u001b[0m in \u001b[0;36m\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" - ] - } - ], + "outputs": [], "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)" + "sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\..\\\\Sources\")) # FOR WINDOWS\n", + "#sys.path.insert(0, os.path.abspath(\"../../../Sources\")) # FOR LINUX" ] }, { - "cell_type": "code", - "execution_count": 1, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "#ИМПОРТ ДИРЕКТОРИИ\n", - "import sys\n", - "import os\n", - "sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\..\\\\KPI_Effect\\\\packages\"))" + "## Шаг 2 - Пишем робота" ] }, { "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]))" + "# Здесь будет код вашего робота...\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" ] }, { - "cell_type": "code", - "execution_count": 14, + "cell_type": "markdown", "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, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "import importlib" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "123\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "importlib.import_module(\".test\",\"pak\")" + "# 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": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "import sys" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sys.modules[\"pak\"]" + "# 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": 1, + "execution_count": null, "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)" + "# 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": [ - { - "data": { - "text/plain": [ - "'2022-09-26 17:59:17'" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "g_datetime_format_str = '%Y-%m-%d %H:%M:%S'\n", - "(datetime.datetime.now()).strftime(g_datetime_format_str)" + "# Clipboard: Взаимодействие с буфером обмена\n", + "from pyOpenRPA.Robot import Clipboard\n", + "\n", + "Clipboard.Set(inTextStr=\"Hello!\")\n", + "lClipStr = Clipboard.Get()\n", + "print(lClipStr)" ] }, { @@ -299,140 +160,49 @@ "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\u001b[0m in \u001b[0;36m\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" + "# 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": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "#ИМПОРТ ДИРЕКТОРИИ\n", - "import sys\n", - "import os\n", - "sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\..\\\\KPI_Effect\\\\packages\"))" + "# 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": 5, + "execution_count": null, "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(\"\")" + "# 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()" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/Tools/Jupyter-notebooks/Quickstart/ScreenItem.png b/Tools/Jupyter-notebooks/Quickstart/ScreenItem.png new file mode 100644 index 0000000000000000000000000000000000000000..ee94f6738f83aa6aaec8e72f555e5917633903a8 GIT binary patch literal 999 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1AIwDK~z{r?U&n2 z6j2<<`)j%oQAW3i2zuxt=&7KG2!!Y*DkFNxdu4R9EHooaQ!L6zSJR5LtD&~WmKEuy ztCkk7o4M;{XLl}p=6w6j*&z{}=2RFx><5OOJ+t$h&(7~R=lo^?{v%Q{PNZa_iFu(P~c>e%;^Lc0u`OxkjgVA~wEYJos{DtH+c)eZ}7M?|MaWTfn z$CKy(0#})u+qaROlY{Q=Zt>5}PyqVl62uBOA)2`u(ZdU8Z@J5$UfGGnn+7B%f*9x@ z5b2V^Ri?e81C>=(7#a+K^>-kCZ5NcBrO69tFNJb+6_kRtP>!vElAnfX){^A0yfo-d z$6<~S+mYOHmEn|@SacfZCm-TvJH$m}C0n80*bALfqd&d~ozi1Gzd|W1f>xJJ!n+YG z+6*OcIn+Cc!KcUUXun3PfcaDi>aBxNtM|ZYuLc`>10IXaD%PJ^shk)A>wN+J5vB9e zcIXezfLjIbf|LyV&;sK{In@h25!MqUi=l!IzJk$m9&GrnJ?M;-j7fobeA52*`|!yS z%-~1+n=?`}Vh;IRB<`r3%s(O}<3viv2{{=fZtwg#Tz8KlCBp*kG*^tyJ>$AzGVrlM zu+OjU0cWIS68@*q@1GLu6Jir`QY2y0s?F$Jtu_HM4Sc8l0wmD-E1PIrTEujGcJf1kIBN<@84CbIR>N&M?L#W#~?@(E!vN`)MU! z0p-Mc(X(hZhoChUh=ow2JEzs>({J_(>FAM_)LyI>E4fU~Sxuar48d7~?naO3>Xd?Y z)Uzy_X{hGdV&^uCwt_2RJHp&pElO)^D@sdCnjbbJI1;29(O`c63^w2e zdv_1U%bPGdYmlH;gAH|w{>Lg{S=!p#(ACu?Cv&~}I?67Wq5NvOIB6EvqiYo~35vIc zKfo$p3n>{-okz%2RaPY%^Lau_CK8FD)7uGukALQsWgd`{`B$W5oJh$yk&>Ak;0L@r V9GaW!v+e)@002ovPDHLkV1fkB%n|?q literal 0 HcmV?d00001