Name | AuPyL JSON |
Version |
0.2
JSON |
| download |
home_page | |
Summary | AutoPy Lite For Termux |
upload_time | 2024-01-12 11:53:30 |
maintainer | |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
## 重要说明
以下参考[AutoPy-Android][url1]库,并在此基础上修改而来
AutoPy Lite原作者[向上的桌子][url2]
[url1]:https://pypi.org/project/AutoPy-Android/
[url2]: https://b23.tv/R6raA5p
## 代码示例
以下示例中的`server_url`参数,默认为`http://127.0.0.1:8020/?code=`
#### 导入库
```python
#模拟点击
from AuPyL import *
from time import sleep
import numpy as np
import cv2 as cv
```
#### 模拟点击操作
`sim_tap(x, y, server_url)`
xy为坐标
```python
#模拟点击
sim_swipe(500,500)
```
#### 模拟滑动
`sim_swipe(x1, y1, x2, y2, t, server_url)`
x1y1为第一个坐标,x2y2为第二个坐标
t为由第一个坐标运动到第二个坐标期望耗时
```python
#模拟滑动操作
sim_swipe(500,0,500,1000,1000)
```
#### 模拟截图
`sim_screenshot(server_url)`
```python
#模拟截图
sim_screenshot()
```
#### 按键模拟
`sim_home(server_url)`
`sim_back(server_url)`
`sim_lockscreen(server_url)`
```python
#按键模拟
sim_home()
sim_back()
sim_lockscreen()
```
#### 文字显示
`PutText(X, Y, W, H, T, S, C, server_url)`
`PutText().show()`显示内容
`PutText().DEL()`清除内容
X : x坐标
Y : y坐标
W: 窗口宽度
H : 窗口高度
T : 内容文本
C : 颜色RGB
```python
txt1 = PutText(X=0, Y=0, W=1000, H=400, T="这是测试文本", S=40, C=(255, 0, 0))
txt1.show()
sleep(3)
for i in range(300):
txt1.T = f"测试文本{i}"
txt1.X += 1
txt1.Y += 2
txt1.C = np.random.randint(0, 255, 3).tolist()
txt1.show()
sleep(0.005)
txt1.DEL
```
#### 按钮
`Button(X, Y, W, H, T, S, C, server_url)`
`Button().show()`显示按钮
`Button().clicks`获取点击次数
`Button().DEL()`删除按钮
参数定义同`PutText`
```python
button1 = Button(T="按钮1", S=20, C=(255, 255, 255), W=300, H=200, X=0, Y=0)
button2 = Button(T="按钮2", S=20, C=(0, 255, 255), W=300, H=200, X=300, Y=0)
button3 = Button(T="点击3次退出", S=20, C=(255, 0, 0), W=300, H=200, X=600, Y=0)
button1.show()
button2.show()
button3.show()
while True:
if button3.clicks >= 3:
button1.DEL()
button2.DEL()
button3.DEL()
break
button1.Y = button1.clicks * 10
button1.C = np.random.randint(0, 255, 3).tolist()
button2.Y = button2.clicks * 10
button2.C = np.random.randint(0, 255, 3).tolist()
button3.T = f"点击{3-button3.clicks}退出"
button1.show()
button2.show()
button3.show()
print(f"\r按钮1 : 点击{button1.clicks}次 按钮2 : 点击{button2.clicks}次", end="")
```
#### 图片显示
`ShowImg(X, Y, W, H, server_url)`
`ShowImg().show(img, OutTime=None)`显示图片
`ShowImg().DEL`清除窗口
```python
img1 = np.random.randint(0, 255, (1080, 1080, 3), dtype=np.uint8)
img2 = "/storage/emulated/0/Pictures/PicsArt/test.jpg"
myshow = ShowImg(W=1000, H=1000, X=0, Y=0)
# 第一个参数接收图片的路径或者一个numpy.ndarray(dtype=uint8)对象,第二个参数为延时关闭窗口,单位:秒,默认None,不自动关闭窗口
myshow.show(img1, OutTime=2)
sleep(3)
myshow.show(img2)
sleep(2)
myshow.DEL()
```
#### 截图
`Screen(server_url)`
`Screen().get(func=None, *args, **kwargs)`获取截图
`Screen().DEL()`停止截图
func : 一个函数地址,将截图经过此函数处理后再返回,`*args, **kwargs`都会传递给func
```python
def drawtext(a, b, c=3):
cv.putText(
a,
f"TEST {b}",
(0, a.shape[0] // 2),
cv.FONT_HERSHEY_SIMPLEX,
c,
(0, 0, 255, 255),
c,
)
return a
show = ShowImg()
show.W = 1088 // 2
show.H = 2333 // 2
show.X = 0
show.Y = 0
screen = Screen()
for i in range(10):
print(i)
show.show(screen.get())
for i in range(10):
print(i)
show.show(screen.get(drawtext, i, c=8))
screen.DEL()
```
Raw data
{
"_id": null,
"home_page": "",
"name": "AuPyL",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "",
"author": "None",
"author_email": "NoneAndNone@No.com",
"download_url": "https://files.pythonhosted.org/packages/d9/4c/0a2344c88a31cb75d85c4216e0dd4ba83131f2b94c8ae2a07ac8150dc949/AuPyL-0.2.tar.gz",
"platform": null,
"description": "## \u91cd\u8981\u8bf4\u660e\n\u4ee5\u4e0b\u53c2\u8003[AutoPy-Android][url1]\u5e93\uff0c\u5e76\u5728\u6b64\u57fa\u7840\u4e0a\u4fee\u6539\u800c\u6765\n\nAutoPy Lite\u539f\u4f5c\u8005[\u5411\u4e0a\u7684\u684c\u5b50][url2]\n\n[url1]:https://pypi.org/project/AutoPy-Android/\n[url2]: https://b23.tv/R6raA5p\n\n\n## \u4ee3\u7801\u793a\u4f8b\n\u4ee5\u4e0b\u793a\u4f8b\u4e2d\u7684`server_url`\u53c2\u6570\uff0c\u9ed8\u8ba4\u4e3a`http://127.0.0.1:8020/?code=`\n\n#### \u5bfc\u5165\u5e93\n```python\n#\u6a21\u62df\u70b9\u51fb\nfrom AuPyL import *\nfrom time import sleep\nimport numpy as np\nimport cv2 as cv\n```\n#### \u6a21\u62df\u70b9\u51fb\u64cd\u4f5c\n`sim_tap(x, y, server_url)`\n\nxy\u4e3a\u5750\u6807\n```python\n#\u6a21\u62df\u70b9\u51fb\nsim_swipe(500,500)\n```\n\n#### \u6a21\u62df\u6ed1\u52a8\n`sim_swipe(x1, y1, x2, y2, t, server_url)`\n\nx1y1\u4e3a\u7b2c\u4e00\u4e2a\u5750\u6807\uff0cx2y2\u4e3a\u7b2c\u4e8c\u4e2a\u5750\u6807\n\nt\u4e3a\u7531\u7b2c\u4e00\u4e2a\u5750\u6807\u8fd0\u52a8\u5230\u7b2c\u4e8c\u4e2a\u5750\u6807\u671f\u671b\u8017\u65f6\n```python\n#\u6a21\u62df\u6ed1\u52a8\u64cd\u4f5c\nsim_swipe(500,0,500,1000,1000)\n```\n#### \u6a21\u62df\u622a\u56fe\n`sim_screenshot(server_url)`\n```python\n#\u6a21\u62df\u622a\u56fe\nsim_screenshot()\n```\n#### \u6309\u952e\u6a21\u62df\n`sim_home(server_url)`\n\n`sim_back(server_url)`\n\n`sim_lockscreen(server_url)`\n```python\n#\u6309\u952e\u6a21\u62df\nsim_home()\nsim_back()\nsim_lockscreen()\n```\n\n#### \u6587\u5b57\u663e\u793a\n`PutText(X, Y, W, H, T, S, C, server_url)`\n\n`PutText().show()`\u663e\u793a\u5185\u5bb9\n\n`PutText().DEL()`\u6e05\u9664\u5185\u5bb9\n\nX : x\u5750\u6807\n\nY : y\u5750\u6807\n\nW: \u7a97\u53e3\u5bbd\u5ea6\n\nH : \u7a97\u53e3\u9ad8\u5ea6\n\nT : \u5185\u5bb9\u6587\u672c\n\nC : \u989c\u8272RGB\n```python\ntxt1 = PutText(X=0, Y=0, W=1000, H=400, T=\"\u8fd9\u662f\u6d4b\u8bd5\u6587\u672c\", S=40, C=(255, 0, 0))\ntxt1.show()\nsleep(3)\nfor i in range(300):\n txt1.T = f\"\u6d4b\u8bd5\u6587\u672c{i}\"\n txt1.X += 1\n txt1.Y += 2\n txt1.C = np.random.randint(0, 255, 3).tolist()\n txt1.show()\n sleep(0.005)\ntxt1.DEL\n```\n\n#### \u6309\u94ae\n`Button(X, Y, W, H, T, S, C, server_url)`\n\n`Button().show()`\u663e\u793a\u6309\u94ae\n\n`Button().clicks`\u83b7\u53d6\u70b9\u51fb\u6b21\u6570\n\n`Button().DEL()`\u5220\u9664\u6309\u94ae\n\n\u53c2\u6570\u5b9a\u4e49\u540c`PutText`\n```python\nbutton1 = Button(T=\"\u6309\u94ae1\", S=20, C=(255, 255, 255), W=300, H=200, X=0, Y=0)\nbutton2 = Button(T=\"\u6309\u94ae2\", S=20, C=(0, 255, 255), W=300, H=200, X=300, Y=0)\nbutton3 = Button(T=\"\u70b9\u51fb3\u6b21\u9000\u51fa\", S=20, C=(255, 0, 0), W=300, H=200, X=600, Y=0)\nbutton1.show()\nbutton2.show()\nbutton3.show()\nwhile True:\n if button3.clicks >= 3:\n button1.DEL()\n button2.DEL()\n button3.DEL()\n break\n button1.Y = button1.clicks * 10\n button1.C = np.random.randint(0, 255, 3).tolist()\n button2.Y = button2.clicks * 10\n button2.C = np.random.randint(0, 255, 3).tolist()\n button3.T = f\"\u70b9\u51fb{3-button3.clicks}\u9000\u51fa\"\n button1.show()\n button2.show()\n button3.show()\n print(f\"\\r\u6309\u94ae1 : \u70b9\u51fb{button1.clicks}\u6b21 \u6309\u94ae2 : \u70b9\u51fb{button2.clicks}\u6b21\", end=\"\")\n```\n\n#### \u56fe\u7247\u663e\u793a\n`ShowImg(X, Y, W, H, server_url)`\n\n`ShowImg().show(img, OutTime=None)`\u663e\u793a\u56fe\u7247\n\n`ShowImg().DEL`\u6e05\u9664\u7a97\u53e3\n```python\nimg1 = np.random.randint(0, 255, (1080, 1080, 3), dtype=np.uint8)\nimg2 = \"/storage/emulated/0/Pictures/PicsArt/test.jpg\"\n\nmyshow = ShowImg(W=1000, H=1000, X=0, Y=0)\n\n# \u7b2c\u4e00\u4e2a\u53c2\u6570\u63a5\u6536\u56fe\u7247\u7684\u8def\u5f84\u6216\u8005\u4e00\u4e2anumpy.ndarray(dtype=uint8)\u5bf9\u8c61,\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u5ef6\u65f6\u5173\u95ed\u7a97\u53e3\uff0c\u5355\u4f4d:\u79d2,\u9ed8\u8ba4None,\u4e0d\u81ea\u52a8\u5173\u95ed\u7a97\u53e3\nmyshow.show(img1, OutTime=2)\nsleep(3)\nmyshow.show(img2)\nsleep(2)\nmyshow.DEL()\n```\n#### \u622a\u56fe\n`Screen(server_url)`\n\n`Screen().get(func=None, *args, **kwargs)`\u83b7\u53d6\u622a\u56fe\n\n`Screen().DEL()`\u505c\u6b62\u622a\u56fe\n\nfunc : \u4e00\u4e2a\u51fd\u6570\u5730\u5740\uff0c\u5c06\u622a\u56fe\u7ecf\u8fc7\u6b64\u51fd\u6570\u5904\u7406\u540e\u518d\u8fd4\u56de,`*args, **kwargs`\u90fd\u4f1a\u4f20\u9012\u7ed9func\n\n```python\ndef drawtext(a, b, c=3):\n cv.putText(\n a,\n f\"TEST {b}\",\n (0, a.shape[0] // 2),\n cv.FONT_HERSHEY_SIMPLEX,\n c,\n (0, 0, 255, 255),\n c,\n )\n return a\n\n\nshow = ShowImg()\nshow.W = 1088 // 2\nshow.H = 2333 // 2\nshow.X = 0\nshow.Y = 0\nscreen = Screen()\nfor i in range(10):\n print(i)\n show.show(screen.get())\nfor i in range(10):\n print(i)\n show.show(screen.get(drawtext, i, c=8))\nscreen.DEL()\n```\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "AutoPy Lite For Termux",
"version": "0.2",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "305ed005a86ae8d5caf354d4f4ed8c69b140b113cde8c0e6f9862d4d87d3a329",
"md5": "ba1437b6cc439086bada26c9d89bdc90",
"sha256": "d032b1403bdf089e1f0923ff348b0c794cfa5877488e0895ede070b98cac4a2b"
},
"downloads": -1,
"filename": "AuPyL-0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ba1437b6cc439086bada26c9d89bdc90",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 9176,
"upload_time": "2024-01-12T11:53:28",
"upload_time_iso_8601": "2024-01-12T11:53:28.984335Z",
"url": "https://files.pythonhosted.org/packages/30/5e/d005a86ae8d5caf354d4f4ed8c69b140b113cde8c0e6f9862d4d87d3a329/AuPyL-0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d94c0a2344c88a31cb75d85c4216e0dd4ba83131f2b94c8ae2a07ac8150dc949",
"md5": "f765168dd4da5cf7cce31ed18e174494",
"sha256": "3429ac1ecddda9e8b0773136fa6ee0971fc56c00fc48f600603f404088408019"
},
"downloads": -1,
"filename": "AuPyL-0.2.tar.gz",
"has_sig": false,
"md5_digest": "f765168dd4da5cf7cce31ed18e174494",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 5795,
"upload_time": "2024-01-12T11:53:30",
"upload_time_iso_8601": "2024-01-12T11:53:30.860544Z",
"url": "https://files.pythonhosted.org/packages/d9/4c/0a2344c88a31cb75d85c4216e0dd4ba83131f2b94c8ae2a07ac8150dc949/AuPyL-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-12 11:53:30",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "aupyl"
}