|
|
@ -0,0 +1,864 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
|
|
<html class="writer-html5" lang="ru" >
|
|
|
|
|
|
|
|
<head>
|
|
|
|
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<title>pyOpenRPA.Robot.Screen — документация pyOpenRPA v1.2.13 v1.2.13</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="shortcut icon" href="../../../_static/favicon.ico"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--[if lt IE 9]>
|
|
|
|
|
|
|
|
<script src="../../../_static/js/html5shiv.min.js"></script>
|
|
|
|
|
|
|
|
<![endif]-->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
|
|
|
|
|
|
|
|
<script src="../../../_static/jquery.js"></script>
|
|
|
|
|
|
|
|
<script src="../../../_static/underscore.js"></script>
|
|
|
|
|
|
|
|
<script src="../../../_static/doctools.js"></script>
|
|
|
|
|
|
|
|
<script src="../../../_static/translations.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="index" title="Алфавитный указатель" href="../../../genindex.html" />
|
|
|
|
|
|
|
|
<link rel="search" title="Поиск" href="../../../search.html" />
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<body class="wy-body-for-nav">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="wy-grid-for-nav">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
|
|
|
|
|
|
<div class="wy-side-scroll">
|
|
|
|
|
|
|
|
<div class="wy-side-nav-search" >
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a href="../../../index.html" class="icon icon-home"> pyOpenRPA v1.2.13
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div role="search">
|
|
|
|
|
|
|
|
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
|
|
|
|
|
|
|
|
<input type="text" name="q" placeholder="Поиск в документации" />
|
|
|
|
|
|
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
|
|
|
|
|
|
<input type="hidden" name="area" value="default" />
|
|
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<p class="caption"><span class="caption-text">ОБЩЕЕ</span></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference external" href="https://pyopenrpa.ru/wiki/guide/index">Выбрать версию</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../01_HowToInstall.html">1. Первый запуск</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../03_Copyrights_Contacts.html">2. Лицензия & Контакты</a></li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p class="caption"><span class="caption-text">МОДУЛЬ РОБОТ</span></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Robot/01_Robot.html">1. Описание</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Robot/02_uidesktop.html">2. Функции UIDesktop</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Robot/03_uiweb.html">3. Функции UIWeb</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Robot/04_keyboard.html">4. Функции Keyboard</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Robot/05_clipboard.html">5. Функции Clipboard</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Robot/06_mouse.html">6. Функции Mouse</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Robot/07_screen.html">7. Функции Screen</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Robot/08_HowToUse.html">8. Как использовать?</a></li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p class="caption"><span class="caption-text">МОДУЛЬ СТУДИЯ</span></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Studio/01_Studio.html">1. Описание</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Studio/02_HowToUse.html">2. Как использовать?</a></li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p class="caption"><span class="caption-text">МОДУЛЬ ОРКЕСТРАТОР</span></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Orchestrator/01_Orchestrator.html">1. Описание</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Orchestrator/02_Defs.html">2. Функции</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Orchestrator/03_gSettingsTemplate.html">3. Настройки GSettings (шаблон)</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Orchestrator/04_HowToUse.html">4. Как использовать?</a></li>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Orchestrator/05_UAC.html">5. Права доступа пользователей UAC</a></li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p class="caption"><span class="caption-text">МОДУЛЬ АГЕНТ</span></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Agent/02_Defs.html">2. Функции</a></li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p class="caption"><span class="caption-text">ИНСТРУМЕНТЫ</span></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
<li class="toctree-l1"><a class="reference internal" href="../../../Tools/02_Defs.html">2. Функции StopSafe</a></li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<nav class="wy-nav-top" aria-label="top navigation">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
|
|
|
|
|
|
<a href="../../../index.html">pyOpenRPA v1.2.13</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="wy-nav-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="rst-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="wy-breadcrumbs">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li><a href="../../../index.html" class="icon icon-home"></a> »</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li><a href="../../index.html">Код модуля</a> »</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li>pyOpenRPA.Robot.Screen</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<hr/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
|
|
|
|
|
|
<div itemprop="articleBody">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h1>Исходный код pyOpenRPA.Robot.Screen</h1><div class="highlight"><pre>
|
|
|
|
|
|
|
|
<span></span><span class="kn">from</span> <span class="nn">pyautogui</span> <span class="kn">import</span> <span class="o">*</span>
|
|
|
|
|
|
|
|
<span class="kn">import</span> <span class="nn">pyautogui</span>
|
|
|
|
|
|
|
|
<span class="kn">import</span> <span class="nn">pyscreeze</span>
|
|
|
|
|
|
|
|
<span class="kn">import</span> <span class="nn">ctypes</span>
|
|
|
|
|
|
|
|
<span class="kn">from</span> <span class="nn">pyOpenRPA.Tools</span> <span class="kn">import</span> <span class="n">CrossOS</span>
|
|
|
|
|
|
|
|
<span class="kn">from</span> <span class="nn">.</span> <span class="kn">import</span> <span class="n">Mouse</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">CrossOS</span><span class="o">.</span><span class="n">IS_WINDOWS_BOOL</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="kn">from</span> <span class="nn">pywinauto</span> <span class="kn">import</span> <span class="n">win32defines</span><span class="p">,</span> <span class="n">win32structures</span><span class="p">,</span> <span class="n">win32functions</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="kn">import</span> <span class="nn">time</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="n">IMAGE_WAIT_SEC_FLOAT</span> <span class="o">=</span> <span class="mi">60</span>
|
|
|
|
|
|
|
|
<span class="n">IMAGE_WAIT_INTERVAL_SEC_FLOAT</span> <span class="o">=</span> <span class="mf">1.0</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="BoxCreate"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.BoxCreate">[документация]</a><span class="k">def</span> <span class="nf">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="p">:</span><span class="nb">int</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="p">:</span><span class="nb">int</span><span class="p">,</span> <span class="n">inHeightInt</span><span class="p">:</span><span class="nb">int</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="p">:</span><span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Box</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Создать экземпляр прямоугольной области.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> !ВНИМАНИЕ! Координаты inTopInt, inLeftInt определяют верхний левый край прямоугольной области.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inTopInt: Координата левой верхней точки в пикселях по оси X (горизонталь)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inTopInt: int</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inLeftInt: Координата левой верхней точки в пикселях по оси Y (вертикаль)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inLeftInt: int</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inHeightInt: Расстояние вниз от левой верхней точки в пикселях</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inHeightInt: int</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWidthInt: Расстояние вправо от левой верхней точки в пикселях</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWidthInt: int</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Box</span><span class="p">(</span><span class="n">top</span> <span class="o">=</span> <span class="n">inTopInt</span><span class="p">,</span> <span class="n">left</span> <span class="o">=</span> <span class="n">inLeftInt</span><span class="p">,</span> <span class="n">height</span> <span class="o">=</span> <span class="n">inHeightInt</span><span class="p">,</span> <span class="n">width</span> <span class="o">=</span> <span class="n">inWidthInt</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="k">def</span> <span class="nf">BoxNormalize</span><span class="p">(</span><span class="o">*</span><span class="n">inArgList</span><span class="p">,</span> <span class="o">**</span><span class="n">inAgrDict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="k">pass</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="BoxMoveTo"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.BoxMoveTo">[документация]</a><span class="k">def</span> <span class="nf">BoxMoveTo</span><span class="p">(</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inDXInt</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">inDYInt</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Переместить прямоугольную область (сохранить длину/ширину).</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> !ВНИМАНИЕ! ПОДДЕРЖИВАЕТ ПАКЕТНУЮ ОБРАТКУ ПРИ ПЕРЕДАЧЕ СПИСКА ЭКЗЕМПЛЯРОВ BOX</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с экраном</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> # Вариант изменения 1-го элемента</span>
|
|
|
|
|
|
|
|
<span class="sd"> # Создать пробную прямоугольную область</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox = Screen.BoxCreate(inTopInt=10, inLeftInt=10, inHeightInt=10, inWidthInt=10)</span>
|
|
|
|
|
|
|
|
<span class="sd"> # Переместить пробную прямоугольную область</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox = Screen.BoxMoveTo(lBox, inDXInt=100, inDYInt=200)</span>
|
|
|
|
|
|
|
|
<span class="sd"> </span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inBox: Экземпляр класса прямоугольной области Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inBox: pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inDXInt: Смещение левой верхней координаты по оси X в пикселях (горизонтальная ось). </span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inDXInt: int, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inDYInt: Смещение левой верхней координаты по оси Y в пикселях (вертикальная ось). </span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inDYInt: int, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :return: Экземпляр класса прямоугольной области Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :rtype: pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">inBox</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">list</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lResult</span> <span class="o">=</span> <span class="p">[]</span>
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">lBox</span> <span class="ow">in</span> <span class="n">inBox</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lResult</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">BoxMoveTo</span><span class="p">(</span><span class="n">lBox</span><span class="p">,</span> <span class="n">inDXInt</span><span class="o">=</span><span class="n">inDXInt</span><span class="p">,</span> <span class="n">inDYInt</span><span class="o">=</span><span class="n">inDYInt</span><span class="p">))</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">lResult</span>
|
|
|
|
|
|
|
|
<span class="k">else</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lTopInt</span> <span class="o">=</span> <span class="n">inBox</span><span class="o">.</span><span class="n">top</span>
|
|
|
|
|
|
|
|
<span class="n">lLeftInt</span> <span class="o">=</span> <span class="n">inBox</span><span class="o">.</span><span class="n">left</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inDXInt</span><span class="p">:</span> <span class="n">lLeftInt</span> <span class="o">=</span> <span class="n">inBox</span><span class="o">.</span><span class="n">left</span> <span class="o">+</span> <span class="n">inDXInt</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inDYInt</span><span class="p">:</span> <span class="n">lTopInt</span> <span class="o">=</span> <span class="n">inBox</span><span class="o">.</span><span class="n">top</span> <span class="o">+</span> <span class="n">inDYInt</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="o">=</span><span class="n">lTopInt</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="o">=</span><span class="n">lLeftInt</span><span class="p">,</span>
|
|
|
|
|
|
|
|
<span class="n">inHeightInt</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">height</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">width</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="BoxModify"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.BoxModify">[документация]</a><span class="k">def</span> <span class="nf">BoxModify</span><span class="p">(</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inDWidthInt</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">inDHeightInt</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">inPointRuleStr</span><span class="o">=</span><span class="s2">"CC"</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Изменить ширину / высоту прямоугольной области.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> !ВНИМАНИЕ! ПОДДЕРЖИВАЕТ ПАКЕТНУЮ ОБРАТКУ ПРИ ПЕРЕДАЧЕ СПИСКА ЭКЗЕМПЛЯРОВ BOX</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> !ВНИМАНИЕ! ЕСЛИ СМЕЩЕНИЕ ПРИВЕДЕТ К ОБРАЗОВАНИЮ ДРОБНОГО ЧИСЛА, БУДЕТ ВЫПОЛНЕНО ОКРУГЛЕНИЕ ПО МАТЕМАТИЧЕСКИМ ПРАВИЛАМ</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с экраном</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> # Вариант изменения 1-го элемента</span>
|
|
|
|
|
|
|
|
<span class="sd"> # Создать пробную прямоугольную область</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox = Screen.BoxCreate(inTopInt=10, inLeftInt=10, inHeightInt=10, inWidthInt=10)</span>
|
|
|
|
|
|
|
|
<span class="sd"> # Скорректировать пробную прямоугольную область</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox2 = Screen.BoxModify(lBox,10,10,"CC"); print(lBox2)</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox2 = Screen.BoxModify(lBox,10,10,"LU"); print(lBox2)</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox2 = Screen.BoxModify(lBox,10,10,"LD"); print(lBox2)</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox2 = Screen.BoxModify(lBox,10,10,"RU"); print(lBox2)</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox2 = Screen.BoxModify(lBox,10,10,"RD"); print(lBox2)</span>
|
|
|
|
|
|
|
|
<span class="sd"> </span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inBox: Экземпляр класса прямоугольной области Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inBox: pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inDXInt: Смещение левой верхней координаты по оси X в пикселях (горизонтальная ось). </span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inDXInt: int, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inDYInt: Смещение левой верхней координаты по оси Y в пикселях (вертикальная ось). </span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inDYInt: int, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inPointRuleStr: Символьное указание точки (подробнее см. выше), относительно которой выполнить изменение прямоугольной области. Допустимые значения: "CC" (по умолчанию), "LU", "LD", "RD", "RU"</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inPointRuleStr: str, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :return: Экземпляр класса прямоугольной области Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :rtype: pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">inBox</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">list</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lResult</span> <span class="o">=</span> <span class="p">[]</span>
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">lBox</span> <span class="ow">in</span> <span class="n">inBox</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lResult</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">BoxModify</span><span class="p">(</span><span class="n">lBox</span><span class="p">,</span> <span class="n">inDWidthInt</span><span class="o">=</span><span class="n">inDWidthInt</span><span class="p">,</span> <span class="n">inDHeightInt</span><span class="o">=</span><span class="n">inDHeightInt</span><span class="p">,</span> <span class="n">inPointRuleStr</span><span class="o">=</span><span class="n">inPointRuleStr</span><span class="p">))</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">lResult</span>
|
|
|
|
|
|
|
|
<span class="k">else</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lTopInt</span> <span class="o">=</span> <span class="n">inBox</span><span class="o">.</span><span class="n">top</span>
|
|
|
|
|
|
|
|
<span class="n">lLeftInt</span> <span class="o">=</span> <span class="n">inBox</span><span class="o">.</span><span class="n">left</span>
|
|
|
|
|
|
|
|
<span class="n">lWidthInt</span> <span class="o">=</span> <span class="n">inBox</span><span class="o">.</span><span class="n">width</span> <span class="o">+</span> <span class="n">inDWidthInt</span>
|
|
|
|
|
|
|
|
<span class="n">lHeightInt</span> <span class="o">=</span> <span class="n">inBox</span><span class="o">.</span><span class="n">height</span> <span class="o">+</span> <span class="n">inDHeightInt</span>
|
|
|
|
|
|
|
|
<span class="n">inPointRuleStr</span> <span class="o">=</span> <span class="n">inPointRuleStr</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="c1"># ВЕРХНИЙ РЕГИСТР</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inDWidthInt</span><span class="p">:</span> <span class="c1"># Изменения по ширине</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="s2">"C"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lLeftInt</span> <span class="o">=</span> <span class="nb">round</span><span class="p">(</span><span class="n">lLeftInt</span> <span class="o">-</span> <span class="n">inDWidthInt</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="s2">"R"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lLeftInt</span> <span class="o">=</span> <span class="n">lLeftInt</span> <span class="o">-</span> <span class="n">inDWidthInt</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inDHeightInt</span><span class="p">:</span> <span class="c1"># Изменения по высоте</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="s2">"C"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lTopInt</span> <span class="o">=</span> <span class="nb">round</span><span class="p">(</span><span class="n">lTopInt</span> <span class="o">-</span> <span class="n">inDHeightInt</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="s2">"D"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lTopInt</span> <span class="o">=</span> <span class="n">lTopInt</span> <span class="o">-</span> <span class="n">inDHeightInt</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="o">=</span><span class="n">lTopInt</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="o">=</span><span class="n">lLeftInt</span><span class="p">,</span>
|
|
|
|
|
|
|
|
<span class="n">inHeightInt</span><span class="o">=</span><span class="n">lHeightInt</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="o">=</span><span class="n">lWidthInt</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="BoxDraw"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.BoxDraw">[документация]</a><span class="k">def</span> <span class="nf">BoxDraw</span><span class="p">(</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inColorStr</span><span class="o">=</span><span class="s1">'green'</span><span class="p">,</span><span class="n">inThicknessInt</span> <span class="o">=</span> <span class="mi">2</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">""" Выполнить подсветку прямоугольной области inBox на экране</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> !ВНИМАНИЕ! РАБОТАЕТ ТОЛЬКО НА ОС WINDOWS</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> !ВНИМАНИЕ! ПОДДЕРЖИВАЕТ ПАКЕТНУЮ ОБРАТКУ ПРИ ПЕРЕДАЧЕ СПИСКА ЭКЗЕМПЛЯРОВ BOX</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с экраном</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> # ВАРИАНТ ОТРИСОВКИ 1ГО ЭЛЕМЕНТА</span>
|
|
|
|
|
|
|
|
<span class="sd"> # Создать пробную прямоугольную область</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox = Screen.BoxCreate(inTopInt=10, inLeftInt=10, inHeightInt=10, inWidthInt=10)</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.BoxDraw(lBox)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # ВАРИАНТ ПАКЕТНОЙ ОТРИСОВКИ</span>
|
|
|
|
|
|
|
|
<span class="sd"> # Создать пробную прямоугольную область</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox = Screen.BoxCreate(inTopInt=10, inLeftInt=10, inHeightInt=100, inWidthInt=100)</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox2 = Screen.BoxCreate(inTopInt=60, inLeftInt=60, inHeightInt=100, inWidthInt=100)</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.BoxDraw([lBox, lBox2])</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inBox: Экземпляр класса прямоугольной области Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inBox: pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inColorStr: цвет подсветки прямоугольной области. Варианты: 'red', 'green', 'blue'. По умолчанию 'green'</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inColorStr: str, необязательный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inThicknessInt: толщина подсветки прямоугольной области. По умолчанию 2</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inThicknessInt: int, необязательный</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">inBox</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">list</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">lBox</span> <span class="ow">in</span> <span class="n">inBox</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">BoxDraw</span><span class="p">(</span><span class="n">inBox</span><span class="o">=</span><span class="n">lBox</span><span class="p">,</span> <span class="n">inColorStr</span><span class="o">=</span><span class="n">inColorStr</span><span class="p">,</span><span class="n">inThicknessInt</span> <span class="o">=</span> <span class="n">inThicknessInt</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">else</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">fill</span> <span class="o">=</span> <span class="n">win32defines</span><span class="o">.</span><span class="n">BS_NULL</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inBox</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="sd">"""</span>
|
|
|
|
|
|
|
|
<span class="sd"> Draw an outline around the window.</span>
|
|
|
|
|
|
|
|
<span class="sd"> * **inColorStr** can be either an integer or one of 'red', 'green', 'blue'</span>
|
|
|
|
|
|
|
|
<span class="sd"> (default 'green')</span>
|
|
|
|
|
|
|
|
<span class="sd"> * **inThicknessInt** inThicknessInt of rectangle (default 2)</span>
|
|
|
|
|
|
|
|
<span class="sd"> * **fill** how to fill in the rectangle (default BS_NULL)</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="c1"># don't draw if dialog is not visible</span>
|
|
|
|
|
|
|
|
<span class="c1">#if not lWrapperObject.is_visible():</span>
|
|
|
|
|
|
|
|
<span class="c1"># return</span>
|
|
|
|
|
|
|
|
<span class="n">colours</span> <span class="o">=</span> <span class="p">{</span>
|
|
|
|
|
|
|
|
<span class="s2">"green"</span><span class="p">:</span> <span class="mh">0x00ff00</span><span class="p">,</span>
|
|
|
|
|
|
|
|
<span class="s2">"blue"</span><span class="p">:</span> <span class="mh">0xff0000</span><span class="p">,</span>
|
|
|
|
|
|
|
|
<span class="s2">"red"</span><span class="p">:</span> <span class="mh">0x0000ff</span><span class="p">,</span>
|
|
|
|
|
|
|
|
<span class="p">}</span>
|
|
|
|
|
|
|
|
<span class="c1"># if it's a known colour</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inColorStr</span> <span class="ow">in</span> <span class="n">colours</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">inColorStr</span> <span class="o">=</span> <span class="n">colours</span><span class="p">[</span><span class="n">inColorStr</span><span class="p">]</span>
|
|
|
|
|
|
|
|
<span class="c1"># create the pen(outline)</span>
|
|
|
|
|
|
|
|
<span class="n">pen_handle</span> <span class="o">=</span> <span class="n">win32functions</span><span class="o">.</span><span class="n">CreatePen</span><span class="p">(</span>
|
|
|
|
|
|
|
|
<span class="n">win32defines</span><span class="o">.</span><span class="n">PS_SOLID</span><span class="p">,</span> <span class="n">inThicknessInt</span><span class="p">,</span> <span class="n">inColorStr</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="c1"># create the brush (inside)</span>
|
|
|
|
|
|
|
|
<span class="n">brush</span> <span class="o">=</span> <span class="n">win32structures</span><span class="o">.</span><span class="n">LOGBRUSH</span><span class="p">()</span>
|
|
|
|
|
|
|
|
<span class="n">brush</span><span class="o">.</span><span class="n">lbStyle</span> <span class="o">=</span> <span class="n">fill</span>
|
|
|
|
|
|
|
|
<span class="n">brush</span><span class="o">.</span><span class="n">lbHatch</span> <span class="o">=</span> <span class="n">win32defines</span><span class="o">.</span><span class="n">HS_DIAGCROSS</span>
|
|
|
|
|
|
|
|
<span class="n">brush_handle</span> <span class="o">=</span> <span class="n">win32functions</span><span class="o">.</span><span class="n">CreateBrushIndirect</span><span class="p">(</span><span class="n">ctypes</span><span class="o">.</span><span class="n">byref</span><span class="p">(</span><span class="n">brush</span><span class="p">))</span>
|
|
|
|
|
|
|
|
<span class="c1"># get the Device Context</span>
|
|
|
|
|
|
|
|
<span class="n">dc</span> <span class="o">=</span> <span class="n">win32functions</span><span class="o">.</span><span class="n">CreateDC</span><span class="p">(</span><span class="s2">"DISPLAY"</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span> <span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="c1"># push our objects into it</span>
|
|
|
|
|
|
|
|
<span class="n">win32functions</span><span class="o">.</span><span class="n">SelectObject</span><span class="p">(</span><span class="n">dc</span><span class="p">,</span> <span class="n">brush_handle</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">win32functions</span><span class="o">.</span><span class="n">SelectObject</span><span class="p">(</span><span class="n">dc</span><span class="p">,</span> <span class="n">pen_handle</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="c1"># draw the rectangle to the DC</span>
|
|
|
|
|
|
|
|
<span class="n">win32functions</span><span class="o">.</span><span class="n">Rectangle</span><span class="p">(</span>
|
|
|
|
|
|
|
|
<span class="n">dc</span><span class="p">,</span> <span class="n">inBox</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">inBox</span><span class="o">.</span><span class="n">top</span><span class="p">,</span> <span class="n">inBox</span><span class="o">.</span><span class="n">left</span><span class="o">+</span><span class="n">inBox</span><span class="o">.</span><span class="n">width</span><span class="p">,</span> <span class="n">inBox</span><span class="o">.</span><span class="n">top</span><span class="o">+</span><span class="n">inBox</span><span class="o">.</span><span class="n">height</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="c1"># Delete the brush and pen we created</span>
|
|
|
|
|
|
|
|
<span class="n">win32functions</span><span class="o">.</span><span class="n">DeleteObject</span><span class="p">(</span><span class="n">brush_handle</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">win32functions</span><span class="o">.</span><span class="n">DeleteObject</span><span class="p">(</span><span class="n">pen_handle</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="c1"># delete the Display context that we created</span>
|
|
|
|
|
|
|
|
<span class="n">win32functions</span><span class="o">.</span><span class="n">DeleteDC</span><span class="p">(</span><span class="n">dc</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="BoxAnchorRuleCheck"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.BoxAnchorRuleCheck">[документация]</a><span class="k">def</span> <span class="nf">BoxAnchorRuleCheck</span><span class="p">(</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inAnchorBox</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">inAnchorRuleStr</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Выполнить проверку соответствия всем условиям вхождения inBox в inAnchorBox с учетом правил inAnchorRule</span>
|
|
|
|
|
|
|
|
<span class="sd"> </span>
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с экраном</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox1 = Screen.BoxCreate(inTopInt=265, inLeftInt=62, inHeightInt=100, inWidthInt=90)</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox2 = Screen.BoxCreate(inTopInt=160, inLeftInt=160, inHeightInt=100, inWidthInt=100)</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox3 = Screen.BoxCreate(inTopInt=460, inLeftInt=60, inHeightInt=100, inWidthInt=100)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> l = Screen.BoxAnchorRuleCheck(inBox=lBox1, inAnchorBox=[lBox2,lBox3], inAnchorRuleStr=["LD","CUS"])</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.BoxDraw([lBox1,lBox2,lBox3])</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inBox: Экземпляр класса прямоугольной области Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inBox: pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inAnchorBox: Экземпляр класса прямоугольной области Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inAnchorBox: pyscreeze.Box или list из pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inAnchorRuleStr: Символьное указание области проверки соответствия. Может принимать единственное значение (единый формат для всех inAnchorBox), или список форматов для каждого inAnchorBox (если inAnchorBox является списком Box)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inAnchorRuleStr: str или list из str</span>
|
|
|
|
|
|
|
|
<span class="sd"> :return: True - соответствует всем правилам</span>
|
|
|
|
|
|
|
|
<span class="sd"> :rtype: bool</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="c1"># Формирование стартовых переменных</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inAnchorBox</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">inAnchorBox</span> <span class="o">=</span> <span class="p">[]</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">inAnchorBox</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="nb">list</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">inAnchorBox</span> <span class="o">=</span> <span class="p">[</span><span class="n">inAnchorBox</span><span class="p">]</span>
|
|
|
|
|
|
|
|
<span class="n">lAnchorRuleStr</span> <span class="o">=</span> <span class="s2">"CC,S"</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inAnchorRuleStr</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">inAnchorRuleStr</span><span class="o">==</span><span class="s2">""</span><span class="p">:</span> <span class="n">inAnchorRuleStr</span> <span class="o">=</span> <span class="p">[</span><span class="n">lAnchorRuleStr</span><span class="p">]</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">inAnchorRuleStr</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="nb">list</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">inAnchorRuleStr</span> <span class="o">=</span> <span class="p">[</span><span class="n">inAnchorRuleStr</span><span class="p">]</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="c1"># Дополнение списка правил до длины якорей, если они расходятся и список правил равен длине 1 или 0 (по умолчанию CC,S)</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">inAnchorRuleStr</span><span class="p">)</span><span class="o">==</span><span class="mi">1</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">inAnchorBox</span><span class="p">)</span><span class="o">==</span><span class="mi">1</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inAnchorRuleStr</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">==</span><span class="s2">""</span> <span class="ow">or</span> <span class="n">inAnchorRuleStr</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">inAnchorRuleStr</span> <span class="o">=</span> <span class="p">[</span><span class="n">lAnchorRuleStr</span><span class="p">]</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">inAnchorRuleStr</span><span class="p">)</span><span class="o">==</span><span class="mi">1</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">inAnchorBox</span><span class="p">)</span><span class="o">!=</span><span class="mi">1</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inAnchorRuleStr</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">!=</span><span class="s2">""</span> <span class="ow">and</span> <span class="n">inAnchorRuleStr</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lAnchorRuleStr</span> <span class="o">=</span> <span class="n">inAnchorRuleStr</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">inAnchorRuleStr</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="n">inAnchorBox</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="n">inAnchorRuleStr</span> <span class="o">=</span> <span class="p">[]</span>
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">lItem</span> <span class="ow">in</span> <span class="n">inAnchorBox</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">inAnchorRuleStr</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">lAnchorRuleStr</span><span class="p">)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">lIndexInt</span><span class="p">,</span> <span class="n">lItemBox</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">inAnchorBox</span><span class="p">):</span> <span class="c1"># Остановиться, если итог False</span>
|
|
|
|
|
|
|
|
<span class="n">lItemRuleStr</span> <span class="o">=</span> <span class="n">inAnchorRuleStr</span><span class="p">[</span><span class="n">lIndexInt</span><span class="p">]</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>
|
|
|
|
|
|
|
|
<span class="nb">print</span><span class="p">(</span><span class="n">lItemRuleStr</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="c1"># Подготовка вспомогательных областей</span>
|
|
|
|
|
|
|
|
<span class="n">lScreenWidthPXInt</span> <span class="o">=</span> <span class="mi">9999</span>
|
|
|
|
|
|
|
|
<span class="n">lScreenHeightPXInt</span> <span class="o">=</span> <span class="mi">5555</span>
|
|
|
|
|
|
|
|
<span class="n">lAnchorLUBox</span> <span class="o">=</span> <span class="n">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">inHeightInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">top</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">left</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">lAnchorRUBox</span> <span class="o">=</span> <span class="n">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">left</span><span class="o">+</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">width</span><span class="p">,</span> <span class="n">inHeightInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">top</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="o">=</span><span class="n">lScreenWidthPXInt</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">lAnchorCUBox</span> <span class="o">=</span> <span class="n">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">inHeightInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">top</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">width</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">lAnchorLCBox</span> <span class="o">=</span> <span class="n">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">top</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">inHeightInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">height</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">left</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">lAnchorRCBox</span> <span class="o">=</span> <span class="n">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">top</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">left</span><span class="o">+</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">width</span><span class="p">,</span> <span class="n">inHeightInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">height</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="o">=</span><span class="n">lScreenWidthPXInt</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">lAnchorLDBox</span> <span class="o">=</span> <span class="n">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">top</span><span class="o">+</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">height</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">inHeightInt</span><span class="o">=</span><span class="n">lScreenHeightPXInt</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">left</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">lAnchorRDBox</span> <span class="o">=</span> <span class="n">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">top</span><span class="o">+</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">height</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">left</span><span class="o">+</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">width</span><span class="p">,</span> <span class="n">inHeightInt</span><span class="o">=</span><span class="n">lScreenHeightPXInt</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="o">=</span><span class="n">lScreenWidthPXInt</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="n">lAnchorCDBox</span> <span class="o">=</span> <span class="n">BoxCreate</span><span class="p">(</span><span class="n">inTopInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">top</span><span class="o">+</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">height</span><span class="p">,</span> <span class="n">inLeftInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">left</span><span class="p">,</span> <span class="n">inHeightInt</span><span class="o">=</span><span class="n">lScreenHeightPXInt</span><span class="p">,</span> <span class="n">inWidthInt</span><span class="o">=</span><span class="n">lItemBox</span><span class="o">.</span><span class="n">width</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="c1">#import pdb</span>
|
|
|
|
|
|
|
|
<span class="c1">#pdb.set_trace()</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="s2">"S"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">:</span> <span class="c1"># Проверка без S - Strict</span>
|
|
|
|
|
|
|
|
<span class="n">lResult</span> <span class="o">=</span> <span class="kc">False</span>
|
|
|
|
|
|
|
|
<span class="c1"># Алгоритм проверки соответствия хотя бы на одно вхождение</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="s2">"CC"</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lItemBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"LU"</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorLUBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"RU"</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorRUBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"CU"</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorCUBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"LC"</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorLCBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"RC"</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorRCBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"LD"</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorLDBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"RD"</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorRDBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"CD"</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorCDBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">lResult</span> <span class="o">==</span> <span class="kc">False</span><span class="p">:</span> <span class="k">break</span> <span class="c1"># Остановиться, если итог False</span>
|
|
|
|
|
|
|
|
<span class="k">else</span><span class="p">:</span> <span class="c1"># Проверка с S - Strict</span>
|
|
|
|
|
|
|
|
<span class="n">lResult</span> <span class="o">=</span> <span class="kc">True</span>
|
|
|
|
|
|
|
|
<span class="c1"># Алгоритм проверки соответствия хотя бы на одно вхождение для того сегмента, который недоступен</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="p">(</span><span class="s2">"CC"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lItemBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">False</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"LU"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorLUBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">False</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"RU"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorRUBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">False</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"CU"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorCUBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">False</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"LC"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorLCBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">False</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"RC"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorRCBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">False</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"LD"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorLDBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">False</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"RD"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorRDBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">False</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="p">(</span><span class="s2">"CD"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lItemRuleStr</span><span class="p">)</span> <span class="ow">and</span> <span class="n">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="o">=</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inBox2</span><span class="o">=</span><span class="n">lAnchorCDBox</span><span class="p">)</span><span class="o">==</span><span class="kc">True</span><span class="p">:</span> <span class="n">lResult</span> <span class="o">=</span> <span class="kc">False</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">lResult</span> <span class="o">==</span> <span class="kc">False</span><span class="p">:</span> <span class="k">break</span> <span class="c1"># Остановиться, если итог False</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">lResult</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="BoxOverlay"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.BoxOverlay">[документация]</a><span class="k">def</span> <span class="nf">BoxOverlay</span><span class="p">(</span><span class="n">inBox1</span><span class="p">,</span> <span class="n">inBox2</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Проверить наложение 2-х прямоугольных областей друг на друга.</span>
|
|
|
|
|
|
|
|
<span class="sd"> </span>
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с экраном</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox1 = Screen.BoxCreate(inTopInt=10, inLeftInt=10, inHeightInt=100, inWidthInt=1000)</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox2 = Screen.BoxCreate(inTopInt=160, inLeftInt=160, inHeightInt=100, inWidthInt=100)</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.BoxDraw([lBox1, lBox2])</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.BoxOverlay(lBox1,lBox2)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inBox1: Экземпляр класса прямоугольной области Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inBox1: pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inBox2: Экземпляр класса прямоугольной области Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inBox2: pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :return: True - inBox1 наложен на inBox2</span>
|
|
|
|
|
|
|
|
<span class="sd"> :rtype: bool</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="ow">not</span> <span class="p">((</span><span class="n">inBox1</span><span class="o">.</span><span class="n">left</span><span class="o">></span><span class="n">inBox2</span><span class="o">.</span><span class="n">left</span> <span class="o">+</span> <span class="n">inBox2</span><span class="o">.</span><span class="n">width</span> <span class="ow">or</span> <span class="n">inBox2</span><span class="o">.</span><span class="n">left</span><span class="o">></span><span class="n">inBox1</span><span class="o">.</span><span class="n">left</span> <span class="o">+</span> <span class="n">inBox1</span><span class="o">.</span><span class="n">width</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">inBox1</span><span class="o">.</span><span class="n">top</span><span class="o">></span><span class="n">inBox2</span><span class="o">.</span><span class="n">top</span> <span class="o">+</span> <span class="n">inBox2</span><span class="o">.</span><span class="n">height</span> <span class="ow">or</span> <span class="n">inBox2</span><span class="o">.</span><span class="n">top</span><span class="o">></span><span class="n">inBox1</span><span class="o">.</span><span class="n">top</span> <span class="o">+</span> <span class="n">inBox1</span><span class="o">.</span><span class="n">height</span><span class="p">))</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="kn">import</span> <span class="nn">re</span>
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="BoxGetPoint"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.BoxGetPoint">[документация]</a><span class="k">def</span> <span class="nf">BoxGetPoint</span><span class="p">(</span><span class="n">inBox</span><span class="p">,</span> <span class="n">inPointRuleStr</span><span class="o">=</span><span class="s2">"CC"</span><span class="p">)</span> <span class="o">-></span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Получить точку pyscreeze.Point по заданной прямоугольной области pyscreeze.Box и строковому параметру расположения inPointRuleStr.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с мышью объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBox1 = Screen.BoxCreate(inTopInt=10, inLeftInt=10, inHeightInt=100, inWidthInt=1000)</span>
|
|
|
|
|
|
|
|
<span class="sd"> lPoint = Screen.BoxGetPoint(inBox=lBox1, inPointRuleStr="LC")</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inBox: Прямоугольная область на экране</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inBox: pyscreeze.Box, обязательный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inPointRuleStr: Правило идентификации точки на прямоугольной области (правила формирования см. выше). Варианты: "LU","CU","RU","LC","CC","RC","LD","CD","RD". По умолчанию "CC"</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inPointRuleStr: str, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :return: Точка на экране</span>
|
|
|
|
|
|
|
|
<span class="sd"> :rtype: pyscreeze.Point</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">lPoint</span> <span class="o">=</span> <span class="kc">None</span>
|
|
|
|
|
|
|
|
<span class="n">inPointRuleStr</span> <span class="o">=</span> <span class="n">inPointRuleStr</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="s2">"CC"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span> <span class="n">lPoint</span> <span class="o">=</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">left</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">width</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">top</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">height</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="s2">"LU"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span> <span class="n">lPoint</span> <span class="o">=</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">left</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">top</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="s2">"RU"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span> <span class="n">lPoint</span> <span class="o">=</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">left</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">width</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">top</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="s2">"CU"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span> <span class="n">lPoint</span> <span class="o">=</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">left</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">width</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">top</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="s2">"LC"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span> <span class="n">lPoint</span> <span class="o">=</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">left</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">top</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">height</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="s2">"RC"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span> <span class="n">lPoint</span> <span class="o">=</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">left</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">width</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">top</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">height</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="s2">"LD"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span> <span class="n">lPoint</span> <span class="o">=</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">left</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">top</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">height</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="s2">"CD"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span> <span class="n">lPoint</span> <span class="o">=</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">left</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">width</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">top</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">height</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">elif</span> <span class="s2">"RD"</span> <span class="ow">in</span> <span class="n">inPointRuleStr</span><span class="p">:</span> <span class="n">lPoint</span> <span class="o">=</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">left</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">width</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">inBox</span><span class="o">.</span><span class="n">top</span> <span class="o">+</span> <span class="n">inBox</span><span class="o">.</span><span class="n">height</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="c1"># Корректировка при необходимости</span>
|
|
|
|
|
|
|
|
<span class="n">lDXInt</span><span class="o">=</span><span class="mi">0</span>
|
|
|
|
|
|
|
|
<span class="n">lDYInt</span><span class="o">=</span><span class="mi">0</span>
|
|
|
|
|
|
|
|
<span class="n">lMatchY</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="sa">r</span><span class="s1">'.*Y([-+]?\d*).*'</span><span class="p">,</span> <span class="n">inPointRuleStr</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">lMatchY</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> <span class="n">lDYInt</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">lMatchY</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
|
|
|
|
|
|
|
|
<span class="n">lMatchX</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="sa">r</span><span class="s1">'.*X([-+]?\d*).*'</span><span class="p">,</span> <span class="n">inPointRuleStr</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">lMatchX</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> <span class="n">lDXInt</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">lMatchX</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
|
|
|
|
|
|
|
|
<span class="n">lPoint</span> <span class="o">=</span> <span class="n">PointModify</span><span class="p">(</span><span class="n">inPoint</span><span class="o">=</span><span class="n">lPoint</span><span class="p">,</span><span class="n">inDXInt</span><span class="o">=</span><span class="n">lDXInt</span><span class="p">,</span><span class="n">inDYInt</span><span class="o">=</span><span class="n">lDYInt</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">lPoint</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="PointModify"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.PointModify">[документация]</a><span class="k">def</span> <span class="nf">PointModify</span><span class="p">(</span><span class="n">inPoint</span><span class="p">,</span> <span class="n">inDXInt</span><span class="p">,</span> <span class="n">inDYInt</span><span class="p">)</span> <span class="o">-></span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Скорректировать точку pyscreeze.Point.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с мышью объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lPoint = Screen.PointCreate(inXInt=10, inYInt=10)</span>
|
|
|
|
|
|
|
|
<span class="sd"> lPoint = Screen.PointModify(inPoint=lPoint, inDXInt=90, inDYInt=10)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inPoint: Точка на экране, по которой выполнить нажатие мыши</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inPoint: pyscreeze.Point, обязательный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inDXInt: Смещение указателя мыши по оси X (горизонтальная ось). </span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inDXInt: int, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inDYInt: Смещение указателя мыши по оси Y (вертикальная ось). </span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inDYInt: int, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :return: Точка на экране</span>
|
|
|
|
|
|
|
|
<span class="sd"> :rtype: pyscreeze.Point</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">PointCreate</span><span class="p">(</span><span class="n">inXInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">x</span><span class="o">+</span><span class="n">inDXInt</span><span class="p">,</span> <span class="n">inYInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">y</span><span class="o">+</span><span class="n">inDYInt</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="PointCreate"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.PointCreate">[документация]</a><span class="k">def</span> <span class="nf">PointCreate</span><span class="p">(</span><span class="n">inXInt</span><span class="p">,</span> <span class="n">inYInt</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Создать точку pyscreeze.Point.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с мышью объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lPoint = Screen.PointCreate(inXInt=10, inYInt=10)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inXInt: Смещение указателя мыши по оси X (горизонтальная ось). </span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inXInt: int, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inYInt: Смещение указателя мыши по оси Y (вертикальная ось). </span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inYInt: int, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :return: Точка на экране</span>
|
|
|
|
|
|
|
|
<span class="sd"> :rtype: pyscreeze.Point</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">inXInt</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">inYInt</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="PointClick"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.PointClick">[документация]</a><span class="k">def</span> <span class="nf">PointClick</span><span class="p">(</span><span class="n">inPoint</span><span class="p">:</span><span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">,</span> <span class="n">inClickCountInt</span><span class="p">:</span><span class="nb">int</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">inIntervalSecFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">inButtonStr</span><span class="p">:</span><span class="nb">str</span><span class="o">=</span><span class="s1">'left'</span><span class="p">,</span> <span class="n">inMoveDurationSecFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">inWaitAfterSecFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Нажатие (вниз) кнопки мыши и затем немедленно выпуск (вверх) её. Допускается следующая параметризация.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с мышью объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lPoint = Screen.PointCreate(100,150)</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.PointClick(lPoint) #Выполнить нажатие левой клавиши мыши</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inPoint: Точка на экране, по которой выполнить нажатие мыши</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inPoint: pyscreeze.Point, обязательный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inClickCountInt: Количество нажатий (вниз и вверх) кнопкой мыши, По умолчанию 1</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inClickCountInt: int, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inIntervalSecFloat: Интервал ожидания в секундах между нажатиями, По умолчанию 0.0</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inIntervalSecFloat: float, опциональный </span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inButtonStr: Номер кнопки, которую требуется нажать. Возможные варианты: 'left', 'middle', 'right' или 1, 2, 3. В остальных случаях инициирует исключение ValueError. По умолчанию 'left'</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inButtonStr: str, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inMoveDurationSecFloat: Время перемещения указателя мыши, По умолчанию 0.0 (моментальное перемещение)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inMoveDurationSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitAfterSecFloat: Количество секунд, которые ожидать после выполнения операции. По умолчанию установлено в настройках модуля Mouse (базовое значение 0.4)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitAfterSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">Mouse</span><span class="o">.</span><span class="n">Click</span><span class="p">(</span><span class="n">inXInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">inYInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">y</span><span class="p">,</span> <span class="n">inClickCountInt</span><span class="o">=</span><span class="n">inClickCountInt</span><span class="p">,</span> <span class="n">inIntervalSecFloat</span><span class="o">=</span><span class="n">inIntervalSecFloat</span><span class="p">,</span> <span class="n">inButtonStr</span><span class="o">=</span><span class="n">inButtonStr</span><span class="p">,</span> <span class="n">inMoveDurationSecFloat</span><span class="o">=</span><span class="n">inMoveDurationSecFloat</span><span class="p">,</span> <span class="n">inWaitAfterSecFloat</span><span class="o">=</span><span class="n">inWaitAfterSecFloat</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="PointClickDouble"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.PointClickDouble">[документация]</a><span class="k">def</span> <span class="nf">PointClickDouble</span><span class="p">(</span><span class="n">inPoint</span><span class="p">:</span><span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">,</span> <span class="n">inWaitAfterSecFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Двойное нажатие левой клавиши мыши. Данное действие аналогично вызову функции (см. ниже).</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с мышью объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lPoint = Screen.PointCreate(100,150)</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.PointClickDouble(lPoint) #Выполнить двойное нажатие левой клавиши мыши</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inPoint: Точка на экране, по которой выполнить нажатие мыши</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inPoint: pyscreeze.Point, обязательный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitAfterSecFloat: Количество секунд, которые ожидать после выполнения операции. По умолчанию установлено в настройках модуля Mouse (базовое значение 0.4)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitAfterSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">Mouse</span><span class="o">.</span><span class="n">ClickDouble</span><span class="p">(</span><span class="n">inXInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">inYInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">y</span><span class="p">,</span> <span class="n">inWaitAfterSecFloat</span><span class="o">=</span><span class="n">inWaitAfterSecFloat</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="PointDown"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.PointDown">[документация]</a><span class="k">def</span> <span class="nf">PointDown</span><span class="p">(</span><span class="n">inPoint</span><span class="p">:</span><span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">,</span> <span class="n">inButtonStr</span><span class="p">:</span><span class="nb">str</span><span class="o">=</span><span class="s1">'left'</span><span class="p">,</span> <span class="n">inWaitAfterSecFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Переместить указатель по координатам inPoint, после чего нажать (вниз) клавишу мыши и не отпускать до выполнения соответсвующей команды (см. Up). </span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с мышью объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lPoint = Screen.PointCreate(100,150)</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.PointDown(lPoint)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inPoint: Точка на экране, по которой выполнить нажатие мыши</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inPoint: pyscreeze.Point, обязательный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inButtonStr: Номер кнопки, которую требуется нажать. Возможные варианты: 'left', 'middle', 'right' или 1, 2, 3. В остальных случаях инициирует исключение ValueError. По умолчанию 'left'</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inButtonStr: str, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitAfterSecFloat: Количество секунд, которые ожидать после выполнения операции. По умолчанию установлено в настройках модуля Mouse (базовое значение 0.4)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitAfterSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">Mouse</span><span class="o">.</span><span class="n">Down</span><span class="p">(</span><span class="n">inXInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">inYInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">y</span><span class="p">,</span><span class="n">inButtonStr</span><span class="o">=</span><span class="n">inButtonStr</span><span class="p">,</span> <span class="n">inWaitAfterSecFloat</span><span class="o">=</span><span class="n">inWaitAfterSecFloat</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="PointUp"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.PointUp">[документация]</a><span class="k">def</span> <span class="nf">PointUp</span><span class="p">(</span><span class="n">inPoint</span><span class="p">:</span><span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">,</span> <span class="n">inButtonStr</span><span class="p">:</span><span class="nb">str</span><span class="o">=</span><span class="s1">'left'</span><span class="p">,</span> <span class="n">inWaitAfterSecFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Отпустить (вверх) клавишу мыши.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с мышью объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lPoint = Screen.PointCreate(100,150)</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.PointUp(lPoint)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inPoint: Точка на экране, по которой выполнить нажатие мыши</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inPoint: pyscreeze.Point, обязательный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inButtonStr: Номер кнопки, которую требуется поднять. Возможные варианты: 'left', 'middle', 'right' или 1, 2, 3. В остальных случаях инициирует исключение ValueError. По умолчанию 'left'</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inButtonStr: str, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitAfterSecFloat: Количество секунд, которые ожидать после выполнения операции. По умолчанию установлено в настройках модуля Mouse (базовое значение 0.4)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitAfterSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">Mouse</span><span class="o">.</span><span class="n">Up</span><span class="p">(</span><span class="n">inXInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">inYInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">y</span><span class="p">,</span><span class="n">inButtonStr</span><span class="o">=</span><span class="n">inButtonStr</span><span class="p">,</span> <span class="n">inWaitAfterSecFloat</span><span class="o">=</span><span class="n">inWaitAfterSecFloat</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="PointMoveTo"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.PointMoveTo">[документация]</a><span class="k">def</span> <span class="nf">PointMoveTo</span><span class="p">(</span><span class="n">inPoint</span><span class="p">:</span><span class="n">pyscreeze</span><span class="o">.</span><span class="n">Point</span><span class="p">,</span> <span class="n">inWaitAfterSecFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Переместить указатель мыши на позицию inXInt, inYInt за время inMoveDurationSecFloat.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> !ВНИМАНИЕ! Отсчет координат inXInt, inYInt начинается с левого верхнего края рабочей области (экрана).</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с мышью объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lPoint = Screen.PointCreate(100,150)</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.PointMoveTo(inXInt=100, inYInt=200)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inPoint: Точка на экране, по которой выполнить нажатие мыши</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inPoint: pyscreeze.Point, обязательный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitAfterSecFloat: Количество секунд, которые ожидать после выполнения операции. По умолчанию установлено в настройках модуля Mouse (базовое значение 0.4)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitAfterSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">Mouse</span><span class="o">.</span><span class="n">MoveTo</span><span class="p">(</span><span class="n">inXInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">inYInt</span><span class="o">=</span><span class="n">inPoint</span><span class="o">.</span><span class="n">y</span><span class="p">,</span> <span class="n">inWaitAfterSecFloat</span><span class="o">=</span><span class="n">inWaitAfterSecFloat</span><span class="p">)</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="ImageLocateAll"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.ImageLocateAll">[документация]</a><span class="k">def</span> <span class="nf">ImageLocateAll</span><span class="p">(</span><span class="n">inImgPathStr</span><span class="p">:</span><span class="nb">str</span><span class="p">,</span> <span class="n">inIsGrayModeBool</span><span class="p">:</span><span class="nb">bool</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">inConfidenceFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Искать на экране графические объекты, которые похожи на inImgPathStr. Вернуть список прямоугольных областей на экране (pyscreeze.Box)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.ImageLocateAll(inImgPathStr="Button.png",inConfidenceFloat=0.9)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inImgPathStr: Путь к изображению, которое требуется искать на экране</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inImgPathStr: str, относительный или абсолютный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inIsGrayModeBool: True - выполнить поиск изображения в режиме серых оттенков (ускоряет производительность, если допускается искажение цвета). По умолчанию False</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inIsGrayModeBool: bool, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inConfidenceFloat: Показатель точности. 1.0 - идентичное соответствие, 0.0 - полное несоответствие. По умолчанию 1.0</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inConfidenceFloat: float, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> :return: Список из pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :rtype: list</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">lResult</span> <span class="o">=</span> <span class="p">[]</span>
|
|
|
|
|
|
|
|
<span class="k">for</span> <span class="n">lItem</span> <span class="ow">in</span> <span class="n">pyautogui</span><span class="o">.</span><span class="n">locateAllOnScreen</span><span class="p">(</span><span class="n">image</span> <span class="o">=</span> <span class="n">inImgPathStr</span><span class="p">,</span> <span class="n">grayscale</span> <span class="o">=</span> <span class="n">inIsGrayModeBool</span><span class="p">,</span> <span class="n">confidence</span> <span class="o">=</span> <span class="n">inConfidenceFloat</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="n">lResult</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">lItem</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">lResult</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="ImageExists"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.ImageExists">[документация]</a><span class="k">def</span> <span class="nf">ImageExists</span><span class="p">(</span><span class="n">inImgPathStr</span><span class="p">:</span><span class="nb">str</span><span class="p">,</span> <span class="n">inIsGrayModeBool</span><span class="p">:</span><span class="nb">bool</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">inConfidenceFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Проверить, имеется ли на экране хотя бы один подходящий объект. Вернуть булево значение</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lResult = Screen.ImageExists(inImgPathStr="Button.png",inConfidenceFloat=0.9)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inImgPathStr: Путь к изображению, которое требуется искать на экране</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inImgPathStr: str, относительный или абсолютный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inIsGrayModeBool: True - выполнить поиск изображения в режиме серых оттенков (ускоряет производительность, если допускается искажение цвета). По умолчанию False</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inIsGrayModeBool: bool, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inConfidenceFloat: Показатель точности. 1.0 - идентичное соответствие, 0.0 - полное несоответствие. По умолчанию 1.0</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inConfidenceFloat: float, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> :return: Список из pyscreeze.Box</span>
|
|
|
|
|
|
|
|
<span class="sd"> :rtype: list</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="n">ImageLocateAll</span><span class="p">(</span><span class="n">inImgPathStr</span><span class="o">=</span><span class="n">inImgPathStr</span><span class="p">,</span><span class="n">inIsGrayModeBool</span><span class="o">=</span><span class="n">inIsGrayModeBool</span><span class="p">,</span> <span class="n">inConfidenceFloat</span><span class="o">=</span><span class="n">inConfidenceFloat</span><span class="p">))</span><span class="o">></span><span class="mi">0</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="ImageWaitAppear"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.ImageWaitAppear">[документация]</a><span class="k">def</span> <span class="nf">ImageWaitAppear</span><span class="p">(</span><span class="n">inImgPathStr</span><span class="p">:</span><span class="nb">str</span><span class="p">,</span> <span class="n">inWaitSecFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="n">IMAGE_WAIT_SEC_FLOAT</span><span class="p">,</span> <span class="n">inWaitIntervalSecFloat</span><span class="p">:</span><span class="nb">float</span> <span class="o">=</span> <span class="n">IMAGE_WAIT_INTERVAL_SEC_FLOAT</span><span class="p">,</span> <span class="n">inIsGrayModeBool</span><span class="p">:</span><span class="nb">bool</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">inConfidenceFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Ожидать появление изображения на протяжении inWaitSecFloat секунд. Проверять с периодичностью inWaitIntervalSecFloat. Вернуть список прямоугольных областей, которые удовлетворяют условию</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> lBoxList = Screen.ImageWaitAppear(inImgPathStr="Button.png",inConfidenceFloat=0.9)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inImgPathStr: Путь к изображению, которое требуется искать на экране</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inImgPathStr: str, относительный или абсолютный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitSecFloat: Время ожидания появления изображения в сек. По умолчанию IMAGE_WAIT_SEC_FLOAT (60)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitIntervalSecFloat: Интервал повторной проверки наличия изображения. По умолчанию IMAGE_WAIT_INTERVAL_SEC_FLOAT (1)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitIntervalSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inIsGrayModeBool: True - выполнить поиск изображения в режиме серых оттенков (ускоряет производительность, если допускается искажение цвета). По умолчанию False</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inIsGrayModeBool: bool, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inConfidenceFloat: Показатель точности. 1.0 - идентичное соответствие, 0.0 - полное несоответствие. По умолчанию 1.0</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inConfidenceFloat: float, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> :return: Список из pyscreeze.Box или [] если прошло время ожидания.</span>
|
|
|
|
|
|
|
|
<span class="sd"> :rtype: list</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">lStartSecFloat</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
|
|
|
|
|
|
|
|
<span class="n">lResultList</span><span class="o">=</span><span class="p">[]</span>
|
|
|
|
|
|
|
|
<span class="k">while</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">-</span> <span class="n">lStartSecFloat</span> <span class="o"><</span> <span class="n">inWaitSecFloat</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lResultList</span> <span class="o">=</span> <span class="n">ImageLocateAll</span><span class="p">(</span><span class="n">inImgPathStr</span><span class="o">=</span><span class="n">inImgPathStr</span><span class="p">,</span><span class="n">inIsGrayModeBool</span><span class="o">=</span><span class="n">inIsGrayModeBool</span><span class="p">,</span> <span class="n">inConfidenceFloat</span><span class="o">=</span><span class="n">inConfidenceFloat</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">lResultList</span><span class="p">)</span><span class="o">></span><span class="mi">0</span><span class="p">:</span> <span class="k">break</span>
|
|
|
|
|
|
|
|
<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="n">inWaitIntervalSecFloat</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">lResultList</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="ImageWaitDisappear"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.ImageWaitDisappear">[документация]</a><span class="k">def</span> <span class="nf">ImageWaitDisappear</span><span class="p">(</span><span class="n">inImgPathStr</span><span class="p">:</span><span class="nb">str</span><span class="p">,</span> <span class="n">inWaitSecFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="n">IMAGE_WAIT_SEC_FLOAT</span><span class="p">,</span> <span class="n">inWaitIntervalSecFloat</span><span class="p">:</span><span class="nb">float</span> <span class="o">=</span> <span class="n">IMAGE_WAIT_INTERVAL_SEC_FLOAT</span><span class="p">,</span> <span class="n">inIsGrayModeBool</span><span class="p">:</span><span class="nb">bool</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">inConfidenceFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">1.0</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Ожидать исчезновение изображения на протяжении inWaitSecFloat секунд. Проверять с периодичностью inWaitIntervalSecFloat.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.ImageWaitDisappear(inImgPathStr="Button.png",inConfidenceFloat=0.9)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inImgPathStr: Путь к изображению, которое требуется искать на экране</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inImgPathStr: str, относительный или абсолютный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitSecFloat: Время ожидания появления изображения в сек. По умолчанию IMAGE_WAIT_SEC_FLOAT (60)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitIntervalSecFloat: Интервал повторной проверки наличия изображения. По умолчанию IMAGE_WAIT_INTERVAL_SEC_FLOAT (1)</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitIntervalSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inIsGrayModeBool: True - выполнить поиск изображения в режиме серых оттенков (ускоряет производительность, если допускается искажение цвета). По умолчанию False</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inIsGrayModeBool: bool, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inConfidenceFloat: Показатель точности. 1.0 - идентичное соответствие, 0.0 - полное несоответствие. По умолчанию 1.0</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inConfidenceFloat: float, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="n">lStartSecFloat</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
|
|
|
|
|
|
|
|
<span class="n">lResultList</span><span class="o">=</span><span class="p">[]</span>
|
|
|
|
|
|
|
|
<span class="k">while</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">-</span> <span class="n">lStartSecFloat</span> <span class="o"><</span> <span class="n">inWaitSecFloat</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lResultList</span> <span class="o">=</span> <span class="n">ImageLocateAll</span><span class="p">(</span><span class="n">inImgPathStr</span><span class="o">=</span><span class="n">inImgPathStr</span><span class="p">,</span><span class="n">inIsGrayModeBool</span><span class="o">=</span><span class="n">inIsGrayModeBool</span><span class="p">,</span> <span class="n">inConfidenceFloat</span><span class="o">=</span><span class="n">inConfidenceFloat</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">lResultList</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">:</span> <span class="k">break</span>
|
|
|
|
|
|
|
|
<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="n">inWaitIntervalSecFloat</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">return</span> <span class="n">lResultList</span></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="viewcode-block" id="ImageClick"><a class="viewcode-back" href="../../../Robot/07_screen.html#pyOpenRPA.Robot.Screen.ImageClick">[документация]</a><span class="k">def</span> <span class="nf">ImageClick</span><span class="p">(</span><span class="n">inImgPathStr</span><span class="p">:</span><span class="nb">str</span><span class="p">,</span><span class="n">inBoxIndexInt</span><span class="p">:</span><span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="n">inPointRuleStr</span><span class="p">:</span><span class="nb">str</span><span class="o">=</span><span class="s2">"CC"</span><span class="p">,</span> <span class="n">inIsGrayModeBool</span><span class="p">:</span><span class="nb">bool</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">inConfidenceFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">inWaitSecFloat</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">inWaitIntervalSecFloat</span><span class="p">:</span><span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span><span class="p">):</span>
|
|
|
|
|
|
|
|
<span class="sd">"""Выполнить поиск прямоугольной области по изображению.</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> .. code-block:: python</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> # Screen: Взаимодействие с объектами экрана</span>
|
|
|
|
|
|
|
|
<span class="sd"> from pyOpenRPA.Robot import Screen</span>
|
|
|
|
|
|
|
|
<span class="sd"> Screen.ImageClick(inImgPathStr="Button.png",inConfidenceFloat=0.9)</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="sd"> :param inImgPathStr: Путь к изображению, которое требуется искать на экране</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inImgPathStr: str, относительный или абсолютный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inBoxIndexInt: Индекс прямоугольной области, по которой выполнить клик (если обнаружено несколько областей Box), По умолчанию 0</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inBoxIndexInt: int, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inPointRuleStr: Правило идентификации точки на прямоугольной области (правила формирования см. выше). Варианты: "LU","CU","RU","LC","CC","RC","LD","CD","RD". По умолчанию "CC"</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inPointRuleStr: str, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inIsGrayModeBool: True - выполнить поиск изображения в режиме серых оттенков (ускоряет производительность, если допускается искажение цвета). По умолчанию False</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inIsGrayModeBool: bool, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inConfidenceFloat: Показатель точности. 1.0 - идентичное соответствие, 0.0 - полное несоответствие. По умолчанию 1.0</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inConfidenceFloat: float, опционально</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitSecFloat: Время ожидания появления изображения в сек. По умолчанию 0</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> :param inWaitIntervalSecFloat: Интервал повторной проверки наличия изображения. По умолчанию 0</span>
|
|
|
|
|
|
|
|
<span class="sd"> :type inWaitIntervalSecFloat: float, опциональный</span>
|
|
|
|
|
|
|
|
<span class="sd"> """</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="n">inWaitSecFloat</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">lBoxList</span> <span class="o">=</span> <span class="n">ImageWaitAppear</span><span class="p">(</span><span class="n">inImgPathStr</span><span class="o">=</span><span class="n">inImgPathStr</span><span class="p">,</span><span class="n">inWaitSecFloat</span><span class="o">=</span><span class="n">inWaitSecFloat</span><span class="p">,</span><span class="n">inWaitIntervalSecFloat</span><span class="o">=</span><span class="n">inWaitIntervalSecFloat</span><span class="p">,</span><span class="n">inIsGrayModeBool</span><span class="o">=</span><span class="n">inIsGrayModeBool</span><span class="p">,</span><span class="n">inConfidenceFloat</span><span class="o">=</span><span class="n">inConfidenceFloat</span><span class="p">)</span>
|
|
|
|
|
|
|
|
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">lBoxList</span><span class="p">)</span><span class="o">></span><span class="mi">0</span><span class="p">:</span> <span class="n">PointClick</span><span class="p">(</span><span class="n">inPoint</span><span class="o">=</span><span class="n">BoxGetPoint</span><span class="p">(</span><span class="n">lBoxList</span><span class="p">[</span><span class="n">inBoxIndexInt</span><span class="p">],</span><span class="n">inPointRuleStr</span><span class="o">=</span><span class="n">inPointRuleStr</span><span class="p">))</span>
|
|
|
|
|
|
|
|
<span class="k">else</span><span class="p">:</span>
|
|
|
|
|
|
|
|
<span class="n">PointClick</span><span class="p">(</span><span class="n">BoxGetPoint</span><span class="p">(</span><span class="n">inBox</span><span class="o">=</span><span class="n">ImageLocateAll</span><span class="p">(</span><span class="n">inImgPathStr</span><span class="o">=</span><span class="n">inImgPathStr</span><span class="p">,</span><span class="n">inIsGrayModeBool</span><span class="o">=</span><span class="n">inIsGrayModeBool</span><span class="p">,</span><span class="n">inConfidenceFloat</span><span class="o">=</span><span class="n">inConfidenceFloat</span><span class="p">)[</span><span class="n">inBoxIndexInt</span><span class="p">],</span><span class="n">inPointRuleStr</span><span class="o">=</span><span class="n">inPointRuleStr</span><span class="p">))</span></div>
|
|
|
|
|
|
|
|
</pre></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<footer>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<hr/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div role="contentinfo">
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
|
|
© Copyright 2022, ООО "ОПЕН РПА".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Собрано при помощи <a href="https://www.sphinx-doc.org/">Sphinx</a> с использованием
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a href="https://github.com/readthedocs/sphinx_rtd_theme">темы,</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
предоставленной <a href="https://readthedocs.org">Read the Docs</a>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</footer>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
jQuery(function () {
|
|
|
|
|
|
|
|
SphinxRtdTheme.Navigation.enable(true);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|