You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Tools/Jupyter-notebooks/Screen.ipynb

261 lines
7.5 KiB

This file contains ambiguous Unicode characters!

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

{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pyautogui\n",
"import sys\n",
"import os\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\Sources\")) # FOR WINDOWS\n",
"sys.path.insert(0, os.path.abspath(\"../../Sources\")) # FOR LINUX \n",
"import time\n",
"from pyOpenRPA.Robot import Screen"
]
},
{
"cell_type": "code",
"execution_count": 2,
"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": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Box(left=348, top=545, width=10, height=11)\n",
"Box(left=365, top=545, width=10, height=11)\n",
"Box(left=407, top=545, width=10, height=11)\n",
"Box(left=424, top=545, width=10, height=11)\n",
"Box(left=483, top=545, width=10, height=11)\n",
"Box(left=500, top=545, width=10, height=11)\n",
"Box(left=542, top=545, width=10, height=11)\n",
"Box(left=559, top=545, width=10, height=11)\n",
"Box(left=601, top=545, width=10, height=11)\n",
"Box(left=618, top=545, width=10, height=11)\n",
"Box(left=660, top=545, width=10, height=11)\n",
"Box(left=677, top=545, width=10, height=11)\n",
"Box(left=736, top=545, width=10, height=11)\n",
"Box(left=753, top=545, width=10, height=11)\n",
"Box(left=795, top=545, width=10, height=11)\n",
"Box(left=812, top=545, width=10, height=11)\n",
"Box(left=854, top=545, width=10, height=11)\n",
"Box(left=871, top=545, width=10, height=11)\n",
"Box(left=913, top=545, width=10, height=11)\n",
"Box(left=930, top=545, width=10, height=11)\n"
]
}
],
"source": [
"#lg= pyautogui.locateAllOnScreen([\"pic.PNG\"], grayscale=False, confidence=0.95)\n",
"lg= pyautogui.locateAllOnScreen(\"pic3.png\")\n",
"lbox = {}\n",
"for litem in lg:\n",
" lbox = litem\n",
" print(litem)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
" # Screen: Взаимодействие с объектами экрана\n",
" from pyOpenRPA.Robot import Screen\n",
" lResult = Screen.ImageExists(inImgPathStr=\"pic.png\",inConfidenceFloat=None)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lResult"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"def BoxOverlay(inBox1, inBox2) -> bool:\n",
"\n",
" return not (inBox1.left>inBox2.left + inBox2.width or inBox2.left>inBox1.left + inBox1.width) or (inBox1.top>inBox2.top + inBox2.height or inBox2.top>inBox1.top + inBox1.height)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"LD\n",
"CUS\n",
"True\n"
]
}
],
"source": [
"lBox1 = Screen.BoxCreate(inTopInt=265, inLeftInt=62, inHeightInt=100, inWidthInt=90)\n",
"lBox2 = Screen.BoxCreate(inTopInt=160, inLeftInt=160, inHeightInt=100, inWidthInt=100)\n",
"lBox3 = Screen.BoxCreate(inTopInt=460, inLeftInt=60, inHeightInt=100, inWidthInt=100)\n",
"\n",
"lScreenWidthPXInt = 2000\n",
"lScreenHeightPXInt = 1000\n",
"\n",
"l = Screen.BoxAnchorRuleCheck(inBox=lBox1, inAnchorBox=[lBox2,lBox3], inAnchorRuleStr=[\"LD\",\"CUS\"])\n",
"Screen.BoxDraw([lBox1,lBox2,lBox3])\n",
"print(l)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"def test(): print(1)\n",
"def test(t): print(2)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "test() missing 1 required positional argument: 't'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-23-fbd55f77ab7c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mtest\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[0m",
"\u001b[1;31mTypeError\u001b[0m: test() missing 1 required positional argument: 't'"
]
}
],
"source": [
"test()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.5"
},
"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
}