{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pyautogui\n", "import sys\n", "import os\n", "sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\Sources\"))\n", "import time\n", "from pyOpenRPA.Robot import Screen" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Box(left=10, top=10, width=100, height=100)\n", "Box(left=110, top=210, width=100, height=100)\n", "Box(left=115, top=215, width=90, height=90)\n", "Box(left=110, top=210, width=90, height=90)\n", "Box(left=110, top=220, width=90, height=90)\n", "Box(left=120, top=210, width=90, height=90)\n", "Box(left=120, top=220, width=90, height=90)\n" ] } ], "source": [ "\n", "# Создать пробную прямоугольную область\n", "lBox = Screen.BoxCreate(inTopInt=10, inLeftInt=10, inHeightInt=100, inWidthInt=100)\n", "lBoxX = Screen.BoxCreate(inTopInt=60, inLeftInt=60, inHeightInt=100, inWidthInt=100)\n", "print(lBox) \n", "# Переместить пробную прямоугольную область\n", "lBox = Screen.BoxMoveTo(lBox, inDXInt=100, inDYInt=200)\n", "print(lBox)\n", "lBox2 = Screen.BoxModify(lBox,-10,-10,\"CC\"); print(lBox2); Screen.BoxDraw([lBox, lBox2, lBoxX])\n", "lBox2 = Screen.BoxModify(lBox,-10,-10,\"LU\"); print(lBox2); #Screen.BoxDraw(lBox2)\n", "lBox2 = Screen.BoxModify(lBox,-10,-10,\"LD\"); print(lBox2); #Screen.BoxDraw(lBox2)\n", "lBox2 = Screen.BoxModify(lBox,-10,-10,\"RU\"); print(lBox2); #Screen.BoxDraw(lBox2)\n", "lBox2 = Screen.BoxModify(lBox,-10,-10,\"RD\"); print(lBox2); #Screen.BoxDraw(lBox2)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "ename": "TypeError", "evalue": "expected an image filename, OpenCV numpy array, or PIL image", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0mlg\u001b[0m\u001b[1;33m=\u001b[0m \u001b[0mpyautogui\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlocateAllOnScreen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"screencontact.PNG\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"screencontact2.PNG\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgrayscale\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfidence\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0.95\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[0mlbox\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[1;32mfor\u001b[0m \u001b[0mlitem\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mlg\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 4\u001b[0m \u001b[0mlbox\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlitem\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlitem\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mC:\\Abs\\Archive\\scopeSrcUL\\pyOpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\site-packages\\pyscreeze\\__init__.py\u001b[0m in \u001b[0;36m_locateAll_opencv\u001b[1;34m(needleImage, haystackImage, grayscale, limit, region, step, confidence)\u001b[0m\n\u001b[0;32m 144\u001b[0m \u001b[0mconfidence\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfloat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mconfidence\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 145\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 146\u001b[1;33m \u001b[0mneedleImage\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_load_cv2\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mneedleImage\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgrayscale\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 147\u001b[0m \u001b[0mneedleHeight\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mneedleWidth\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mneedleImage\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 148\u001b[0m \u001b[0mhaystackImage\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_load_cv2\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhaystackImage\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgrayscale\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mC:\\Abs\\Archive\\scopeSrcUL\\pyOpenRPA\\Resources\\WPy64-3720\\python-3.7.2.amd64\\lib\\site-packages\\pyscreeze\\__init__.py\u001b[0m in \u001b[0;36m_load_cv2\u001b[1;34m(img, grayscale)\u001b[0m\n\u001b[0;32m 125\u001b[0m \u001b[0mimg_cv\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcv2\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcvtColor\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mimg_cv\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcv2\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mCOLOR_BGR2GRAY\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 126\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 127\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'expected an image filename, OpenCV numpy array, or PIL image'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 128\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mimg_cv\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 129\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mTypeError\u001b[0m: expected an image filename, OpenCV numpy array, or PIL image" ] } ], "source": [ "lg= pyautogui.locateAllOnScreen([\"screencontact.PNG\", \"screenconta-ct2.PNG\"], grayscale=False, confidence=0.95)\n", "lbox = {}\n", "for litem in lg:\n", " lbox = litem\n", " print(litem)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "ename": "AttributeError", "evalue": "'Box' object has no attribute 'sads'", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mlBox\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msads\u001b[0m\u001b[1;33m=\u001b[0m \u001b[1;36m20\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;31mAttributeError\u001b[0m: 'Box' object has no attribute 'sads'" ] } ], "source": [ "lBox.sads= 20" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type([]) is list" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }