### Image Search from File Example
Source: https://docs.trollautoscript.com/docs/%E5%9B%BE%E7%89%87%E5%AF%B9%E8%B1%A1%E6%A8%A1%E5%9D%97/%E5%9C%A8%E5%9B%BE%E7%89%87%E4%B8%AD%E6%89%BE%E5%9B%BE%2BfindImage%2B%2B0a87acb8-a79b-4deb-8489-a9033995ad45
This example shows how to load an image from a file and search for it on the screen using :findImage.
```lua
--另一个示例 从图片文件加载图片对象
local x ,y = imgObj:findImage(screen.loadImageFile("/var/mobile/Media/test.png"))--全屏找图
if x ~= -1 and y ~= -1 then
print(string.format("成功找到图片拉坐标: x= %d, y= %d" ,x ,y))
end
```
--------------------------------
### Basic Image Search Example
Source: https://docs.trollautoscript.com/docs/%E5%9B%BE%E7%89%87%E5%AF%B9%E8%B1%A1%E6%A8%A1%E5%9D%97/%E5%9C%A8%E5%9B%BE%E7%89%87%E4%B8%AD%E6%89%BE%E5%9B%BE%2BfindImage%2B%2B0a87acb8-a79b-4deb-8489-a9033995ad45
A simple example demonstrating how to capture a screenshot and search for it within the entire screen using :findImage.
```lua
--简单的示例 从屏幕创建图片对象
local imgObj = screen.image() --全屏截图
local img = screen.image(100,100,200,200) --随便截个图 用来测试找图
local x ,y = imgObj:findImage(img) --全屏找图
if x ~= -1 and y ~= -1 then
print(string.format("成功找到图片拉坐标: x= %d, y= %d" ,x ,y))
end
```
--------------------------------
### Example Usage of node.info()
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E5%89%8D%E5%8F%B0%E5%BA%94%E7%94%A8%E7%9A%84%E8%8A%82%E7%82%B9%E4%BF%A1%E6%81%AF%2Bnode.info%2B%2Bbae5301e-0113-4836-814d-38cfac8c88c6
This example demonstrates how to use the `node.info()` function to fetch node information and print it. It requires the `nodeLua` module. Successful execution returns node information; failure returns nil.
```lua
local node = require("nodeLua")
local info = node.info()
print(info) -- 成功将返回 节点信息 失败返回nil
```
--------------------------------
### Get Application Install Path
Source: https://docs.trollautoscript.com/docs/%E5%BA%94%E7%94%A8%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E5%AE%89%E8%A3%85%E8%B7%AF%E5%BE%84%2Bapp.installPath%2B%2Bf570a5c4-1d95-4f5c-aeac-999dceda495b
Retrieves the installation path of an application given its bundle ID.
```APIDOC
## GET app.installPath
### Description
Used to obtain the installation path of an app.
### Method
GET
### Endpoint
`/app/installPath`
### Parameters
#### Query Parameters
- **applicationBundleId** (string) - Required - The bundle ID of the application.
### Response
#### Success Response (200)
- **path** (string) - The installation path of the application.
#### Response Example
```json
{
"path": "/path/to/application"
}
```
### Example Usage
```javascript
let path = app.installPath("com.ss.iphone.ugc.aweme.lite");
console.log("The application installation path is:" + path);
```
```
--------------------------------
### GetSubNode Usage Example
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E5%AD%90%E8%8A%82%E7%82%B9%2BGetSubNode%2B%2Ba7e98f09-ea44-4729-8d7f-5e4c25441d10
Example demonstrating how to find a node by label and retrieve its specific child nodes.
```lua
local node = require("nodeLua")
local nodeInfo = node.byLable('猜你想搜,标题' ,'LynxTextView')
--查找路径
if (nodeInfo) then
print(nodeInfo[1]:GetSubNode("UILabel")) --打印当前节点的 子节点
end
```
--------------------------------
### Write Text to File Example
Source: https://docs.trollautoscript.com/docs/%E6%96%87%E4%BB%B6%E6%A8%A1%E5%9D%97/%E5%86%99%E5%85%A5%E6%96%87%E6%9C%AC%E5%88%B0%E6%96%87%E4%BB%B6%2Bfile.writes%2B%2B1e2042d8-5b8e-428f-b9ab-f4ed0c52e62f
Example demonstrating how to use file.writes to overwrite a text file. Ensure the file path is correct and the script has write permissions.
```lua
if (file.writes("/var/mobile/Media/1.txt" ,"随便写点数据进去")) then
print("写入成功")
end
```
--------------------------------
### Example: Get Instance Class Name
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97new/className
This example demonstrates how to match a node based on its label and class, then retrieve and print its class name using the :className() method. The second parameter 'true' returns an array of node objects.
```lua
local node = nodeView.matchForMainWindow(function (info) --匹配节点信息 label==点赞 class==AWEFeedVideoButton 此函数返回节点对象数组 数组型
return info.label == "点赞" and info.class == "AWEFeedVideoButton"
end ,true) --第二个参数为 true 时 返回 对象数组
print(node[1]:className()) --打印出地址属性
```
--------------------------------
### Check and Enable Flashlight
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/%E5%BC%80%E6%89%93%E9%97%AA%E5%85%89%E7%81%AF%2Bdevice.turnOnFlash%2B%2B11713f3b-fc7e-4708-ad8d-381879fb15c7
Example showing how to check if the flashlight is enabled before turning it on.
```javascript
if not device.isFlashEnabled() then
print("闪光灯 未启用")
device.turnOnFlash() -- 打开闪光灯
end
```
--------------------------------
### Check application installation status
Source: https://docs.trollautoscript.com/docs/%E5%BA%94%E7%94%A8%E6%A8%A1%E5%9D%97/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E6%98%AF%E5%90%A6%E5%AE%89%E8%A3%85%2Bapp.isInstalled%2B%2Bf6132899-04bb-4842-bd4e-5d174e86bad2
Use this snippet to verify if a specific application is installed by providing its bundle ID.
```lua
if app.isInstalled("com.ss.iphone.ugc.aweme.lite") then
print("应用已安装")
else
print("应用未安装")
end
```
--------------------------------
### Example Usage of GetLable
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E8%8A%82%E7%82%B9%E6%A0%87%E9%A2%98%2BGetLable%2B%2B7302f3df-7dc0-4675-8f7b-2af6e0dbf377
This example demonstrates how to find a node by its label and then retrieve its title using GetLable. Ensure the 'nodeLua' module is required.
```Lua
local node = require("nodeLua")
local nodeInfo = node.byLable('猜你想搜,标题' ,'LynxTextView')
--查找路径
if (nodeInfo) then
print(nodeInfo[1]:GetLable()) --打印当前节点 标题
end
```
--------------------------------
### Save Screenshot to PNG File
Source: https://docs.trollautoscript.com/docs/%E5%9B%BE%E7%89%87%E5%AF%B9%E8%B1%A1%E6%A8%A1%E5%9D%97/%E4%BF%9D%E5%AD%98%E5%9B%BE%E7%89%87%E5%88%B0JPG%E6%96%87%E4%BB%B6%2BsaveToJpegFile%2B%2Beade1cac-4bf0-4bbd-9eaf-b99b400ba73d
This example demonstrates capturing a screenshot and saving it to a PNG file. Note that the example saves to a .png extension, not .jpg as the function name might imply.
```script
--简单的示例
screen.image():saveToJpegFile("/var/mobile/Media/test.png") --截图并保存到PNG文件
```
--------------------------------
### Train YOLO11 on Windows with NVIDIA GPU
Source: https://docs.trollautoscript.com/docs/coreML%E6%A8%A1%E5%9D%97/%E5%A6%82%E4%BD%95%E8%AE%AD%E7%BB%83%2Bc4cf1f78-8daa-4325-8f1e-d6358ba31002
Install necessary prerequisites like Visual Studio C++ build tools and CUDA Toolkit 11.8. Ensure Python 3.10 is set up. Install the ultralytics package and PyTorch with CUDA 11.8 support. Then, run the training command specifying the GPU device.
```bash
# 先在电脑安装 Visual Studio 的 C++ 桌面开发套件,如果已安装则跳过这一步,以下是链接
# https://visualstudio.microsoft.com/
# 在电脑上下载安装 CUDA 11.8 Toolkit,如果已安装则跳过这一步,以下是链接
# https://developer.nvidia.com/cuda-11-8-0-download-archive
# 这里假设你已经有 Python 3.10 环境,没有请自行创建(本人仅用 Python 3.10 环境测试,更高版本不确定是否可行)
# 先安装 ultralytics,如果已安装则跳过这一步
pip install ultralytics
# 重新安装支持 nVIDIA CUDA 11.8 Toolkit 的 torch 库
# 如果确认安装过了支持 CUDA 的 torch 库则跳过这一步
pip uninstall torch torchvision torchaudio # 卸载掉电脑上已安装的 CPU 版 torch (假设安装了)
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118
yolo train model=yolo11m.pt data=COCO.yml epochs=300 imgsz=640 device=0 # 使用 GPU0 对样本进行训练
```
--------------------------------
### Create and Manage Threads
Source: https://docs.trollautoscript.com/docs/%E7%BA%BF%E7%A8%8B%E6%A8%A1%E5%9D%97/%E7%BA%BF%E7%A8%8B%E7%8A%B6%E6%80%81%2Bthread.state%2B%2Becbf12dc-254d-412a-a013-219333c3532a
Example demonstrating thread creation, state retrieval, and main thread execution. Note that the script stops if the main thread stops, regardless of child threads.
```lua
local co , success, err = thread.create(function() --创建线程
for i = 1, 10 do
print("线程1 :" , i)
sys.msleep(500) --这个函数 会让出线程 其他线程将会得到运行机会
end
end)
if success then
print("线程创建成功")
else
print("线程创建错误:" ,err)
end
print(thread.state(co)) --获取线程的当前状态 此处应为 暂停状态
for i = 1, 10 do --主线程 当主线程停止 不管子线程是否结束 都会停止脚本
print("主线程 :" , i)
sys.msleep(1000)
end
```
--------------------------------
### Simulate Touch on Node Center (:OnTap)
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97/%E8%A7%A6%E6%91%B8%E4%B8%80%E6%AC%A1%E8%8A%82%E7%82%B9%2BOnTap%2B%2B16971656-152b-4ed6-b70e-632d82dfb6e7
This example demonstrates how to find a node by its text and type, and then simulate a single tap at its center using the :OnTap() function. Ensure the 'nodeLua' module is required.
```lua
local node = require("nodeLua")
local nodeInfo = node.byText('动态' ,'LynxTextView')
if (nodeInfo) then
print(nodeInfo[1]:OnTap()) --触摸节点中心位置
end
```
--------------------------------
### Initialize, Show, and Release Screen Drawing Object
Source: https://docs.trollautoscript.com/docs/%E5%B1%8F%E5%B9%95%E7%BB%98%E5%88%B6%E6%A8%A1%E5%9D%97/%E6%89%8B%E5%8A%A8%E9%87%8A%E6%94%BE%2Brelease%2B%2B17cdf46f-6a4d-4995-8e6c-7dbfa3323ca9
Example demonstrating the creation, display, and manual release of a screen drawing object. This shows the lifecycle from initialization to memory deallocation.
```lua
--在屏幕 100,200 的位置创建一个 宽度100 高度100的 屏幕绘制对象
local sd = screenDraw.init(100,200,100,100)
sd:show() --在屏幕上显示
sd:release() --手动销毁对象 立即释放内存
```
--------------------------------
### GET sys.version
Source: https://docs.trollautoscript.com/docs/%E7%B3%BB%E7%BB%9F%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96TAS%E7%89%88%E6%9C%AC%2Bsys.version%2B%2B51c44ec9-2331-4357-bc11-5b8ac2f66589
Retrieves the current version information of the TrollAutoScript environment.
```APIDOC
## GET sys.version
### Description
Returns the version information of the TrollAutoScript environment.
### Method
GET
### Endpoint
sys.version()
### Response
#### Success Response (200)
- **版本号** (文本型) - The version string of the TrollAutoScript environment.
#### Response Example
```lua
local TASVersion = sys.version()
print(TASVersion)
```
```
--------------------------------
### Initialize and Use TomatoOCR for Screen Text Recognition
Source: https://docs.trollautoscript.com/docs/%E5%B1%8F%E5%B9%95%E6%A8%A1%E5%9D%97/TomatoOCR
This example demonstrates how to initialize TomatoOCR, set recognition parameters, and perform OCR on a specified screen region or image file. It includes options for different recognition types, detection box types, and return formats. Ensure the resource path for initialization is correct.
```lua
local tomatoOCR = require("TomatoOCR")
function ocr_start(x1, y1, x2, y2, zi)
local rec_type = "ch-3.0";
-- 注:ch、ch-2.0、ch-3.0版可切换使用,对部分场景可适当调整
-- "ch":普通中英文识别,1.0版模型
-- "ch-2.0":普通中英文识别,2.0版模型
-- "ch-3.0":普通中英文识别,3.0版模型
-- "number":数字识别
-- "cht":繁体,"japan":日语,"korean":韩语
tomatoOCR.setRecType(rec_type)
tomatoOCR.setDetBoxType("rect") -- 调整检测模型检测文本参数- 默认"rect": 由于手机上截图文本均为矩形文本,从该版本之后均改为rect,"quad":可准确检测倾斜文本
tomatoOCR.setDetUnclipRatio(1.9) -- 调整检测模型检测文本参数 - 默认1.9: 值范围1.6-2.5之间
tomatoOCR.setRecScoreThreshold(0.1) -- 识别得分过滤 - 默认0.1,值范围0.1-0.9之间
tomatoOCR.setReturnType("json")
-- 返回类型 - 默认"json": 包含得分、坐标和文字;
-- "text":纯文字;
-- "num":纯数字;
-- 自定义输入想要返回的文本:".¥1234567890",仅只返回这些内容
tomatoOCR.setBinaryThresh(0) -- 二值化设定,非必须
tomatoOCR.setFilterColor("", "black"); -- 设置滤色值和背景色(black\white),滤色值默认是空的,详细使用见方法说明
local type = 3;
-- type 可传可不传
-- type=0 : 只检测
-- type=1 : 方向分类 + 识别
-- type=2 : 只识别
-- type=3 : 检测 + 识别
-- 只检测文字位置:type=0
-- 全屏识别: type=3或者不传type
-- 截取单行文字识别:type=1或者type=2
local img = "/var/mobile/Media/1.png"
screen.image(x1, y1, x2, y2):saveToPngFile(img)
local res = tomatoOCR.ocrFile(img, type)
print("结果:"..res)
-- 找字返回坐标,返回的是“百度”的中心点坐标,没有找到字返回“”空字符串
local point = tomatoOCR.findTapPoint(zi)
print(point)
-- 找字返回坐标,返回所有的“百度”的中心点坐标,没有找到字返回“”空字符串
local points = tomatoOCR.findTapPoints(zi)
print(points)
end
function main()
local path = "/var/mobile/Media/svip/"
-- 初始化-ios
tomatoOCR.init(path.."/res/")
local license = "" -- 授权码
local remark = "" -- 备注
local flag = tomatoOCR.setLicense(license, remark)
print(flag)
ocr_start(0, 0, 300, 300, "百度")
end
main()
```
--------------------------------
### Node Keep Usage Example
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97/%E8%8A%82%E7%82%B9%E4%BF%9D%E6%8C%81%2Bnode.keep%2B%2Bff737045-74a7-454f-b1f7-38896df7280c
Demonstrates how to invoke node.keep before performing a node lookup to improve performance.
```lua
local node = require("nodeLua")
node.keep() -- 保持当前节点 提升节点查找性能
local nodeInfo = node.byText("我") -- 查找文本为 我 的节点
print(nodeInfo) --打印结果
```
--------------------------------
### Example usage of string.isUpper
Source: https://docs.trollautoscript.com/docs/%E6%89%A9%E5%B1%95string%E6%A8%A1%E5%9D%97/%E6%98%AF%E5%90%A6%E6%98%AF%E5%A4%A7%E5%86%99%E5%AD%97%E6%AF%8D%2Bstring.isUpper%2B%2Bc9990f44-7a09-4d20-892a-f4c4b2c843eb
Demonstrates the function behavior with numeric, lowercase, and uppercase inputs.
```lua
string.isUpper("1") -- 返回false
string.isUpper("a") -- 返回false
string.isUpper("A") -- 返回true
```
--------------------------------
### GET app.frontBid()
Source: https://docs.trollautoscript.com/docs/%E5%BA%94%E7%94%A8%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E5%89%8D%E5%8F%B0%E5%BA%94%E7%94%A8bundleId%2Bapp.frontBid%2B%2Bbb66fe0f-0824-44fe-99e6-3f751dc52c4d
Retrieves the bundle identifier of the application currently running in the foreground.
```APIDOC
## GET app.frontBid()
### Description
Retrieves the bundle identifier (bundleId) of the application currently running in the foreground.
### Method
GET
### Endpoint
app.frontBid()
### Response
- **bundleId** (string) - The bundle identifier of the foreground application.
### Request Example
```lua
if app.frontBid() ~= "com.ss.iphone.ugc.aweme.lite" then
app.run("com.ss.iphone.ugc.aweme.lite")
sys.msleep(3000)
end
```
```
--------------------------------
### Clear Safari Cookies Implementation Example
Source: https://docs.trollautoscript.com/docs/%E6%B8%85%E7%90%86%E6%A8%A1%E5%9D%97/%E6%B8%85%E7%90%86safari%2BCookies%2Bclear.safariCookies%2B%2B5c5402f8-2508-4806-9105-ea98d2decb8d
Demonstrates how to safely clear Safari sandbox data by verifying the path before execution.
```lua
clear.safariCookies() --清理cookies
local path = app.dataPath("com.apple.mobilesafari")
if path and path ~= "" and path:find("/var/") then --查找是否有 /var/ 路径 预防 直接执行 rm -rf /*
os.execute(string.format("rm -rf %s/*" ,path)) --清除应用沙盒数据
end
```
--------------------------------
### Example Usage of GetSuperNode
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E7%88%B6%E8%8A%82%E7%82%B9%2BGetSuperNode%2B%2B18ff2611-9af6-4337-bb03-6d73e7852e9a
Demonstrates how to use the GetSuperNode function to print the parent node of a found node. Ensure the 'nodeLua' module is required.
```lua
local node = require("nodeLua")
local nodeInfo = node.byLable('猜你想搜,标题' ,'LynxTextView')
--查找路径
if (nodeInfo) then
print(nodeInfo[1]:GetSuperNode()) --打印当前节点的 父节点
end
```
--------------------------------
### Initialize Log Window
Source: https://docs.trollautoscript.com/docs/%E6%97%A5%E5%BF%97%E7%AA%97%E5%8F%A3%E6%A8%A1%E5%9D%97/%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%97%A5%E5%BF%97%E7%AA%97%E5%8F%A3%2BlogWindow.init%2B%2B12ea4400-dde8-4423-9035-af70d35255ed
Creates a log window at the specified screen coordinates with default width and height. Use this to quickly set up a basic log display.
```lua
local lw = logWindow.init(100,100) --在屏幕位置 100-100的位置创建一个 宽度为500 高度为 35的 日志显示窗口
```
--------------------------------
### 初始化webView视图
Source: https://docs.trollautoscript.com/docs/webView%E6%A8%A1%E5%9D%97/%E5%88%9B%E5%BB%BAwebView%E8%A7%86%E5%9B%BE%2BwebView.init%2B%2B2ec42f5d-deaf-49cc-9dfa-da6fa1647984
展示了如何使用webView.init函数创建一个webView视图,并配置其坐标、尺寸、内容源及交互属性。
```lua
local view = webView.init{
x = 300, --屏幕横坐标 int 整数 必填
y = 300, -- 屏幕纵坐标 int 整数 必填
width = 800, -- 宽度 int 整数 必填
height = 1000, --高度 int 整数 必填
html = "
我去年买了个表
", -- html 可选 和url 字段 必须存在一项 文本
url = "https://www.baidu.com", -- url, 可选 和HTML 字段 必须存在一项 优先显示
alpha = 100, -- 透明度 可选 默认 0 -100 整数 默认100
-- rotate = 90, --向右旋转90度 可选 -90 为左旋转。 默认 0
radius = 5.0, -- 圆角 可选
hit = true, --是否可拖动 可选 默认 true
userInteractionEnabled = true -- 是否可交互 为false 时 拖动失效 可选 默认 true
}
sys.msleep(10000) --延迟10秒 在停止脚本
```
--------------------------------
### Usage Examples for :cvFindImage
Source: https://docs.trollautoscript.com/docs/%E5%9B%BE%E7%89%87%E5%AF%B9%E8%B1%A1%E6%A8%A1%E5%9D%97/openCV%E5%9B%BE%E4%B8%AD%E6%89%BE%E5%9B%BE%2BcvFindImage%2B%2B3b716798-81f5-4eab-a40b-7eadab4b92be
Various ways to use cvFindImage, including full-screen searches and region-specific searches with similarity thresholds.
```lua
--简单的示例 从屏幕创建图片对象
local imgObj = screen.image() --全屏截图
local img = screen.image(100,100,200,200) --随便截个图 用来测试找图
local x ,y = imgObj:cvFindImage(img) --全屏找图
if x ~= -1 and y ~= -1 then
print(string.format("成功找到图片拉坐标: x= %d, y= %d" ,x ,y))
end
--另一个示例 从图片文件加载图片对象
local x ,y = imgObj:cvFindImage(screen.loadImageFile("/var/mobile/Media/test.png"))--全屏找图
if x ~= -1 and y ~= -1 then
print(string.format("成功找到图片拉坐标: x= %d, y= %d" ,x ,y))
end
--另一个示例 从图片文件加载图片对象
local x ,y = imgObj:cvFindImage(screen.loadImageFile("/var/mobile/Media/test.png") , 90
100,100,400,600 ) --范围找图 且相似度为 90
if x ~= -1 and y ~= -1 then
print(string.format("成功找到图片拉坐标: x= %d, y= %d" ,x ,y))
end
```
--------------------------------
### Get Node Array
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E5%89%8D%E5%8F%B0%E5%BA%94%E7%94%A8%E7%9A%84%E8%8A%82%E7%82%B9%E4%BF%A1%E6%81%AF%2Bnode.info%2B%2Bbae5301e-0113-4836-814d-38cfac8c88c6
This function retrieves an array containing information about all nodes in the current foreground application. It is intended for use with applications installed from the Apple Store.
```lua
节点数组 = node.info()
```
--------------------------------
### Simulate a Basic Screen Tap
Source: https://docs.trollautoscript.com/docs/%E6%A8%A1%E6%8B%9F%E8%A7%A6%E6%91%B8%E6%A8%A1%E5%9D%97/%E8%A7%A6%E6%91%B8%E4%B8%80%E6%AC%A1%E5%B1%8F%E5%B9%95%2Btouch.tap%2B%2Bf84f027d-318d-4fce-9fe8-9d89fb1abdc4
Use touch.tap with coordinates to simulate a simple screen tap. No additional setup is required.
```lua
touch.tap(100,100)
```
--------------------------------
### Check if Application is Installed
Source: https://docs.trollautoscript.com/docs/%E5%BA%94%E7%94%A8%E6%A8%A1%E5%9D%97/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E6%98%AF%E5%90%A6%E5%AE%89%E8%A3%85%2Bapp.isInstalled%2B%2Bf6132899-04bb-4842-bd4e-5d174e86bad2
This endpoint checks if a specific application is installed on the device using its bundle ID.
```APIDOC
## GET /app/isInstalled
### Description
Used to determine if an application is installed.
### Method
GET
### Endpoint
/app/isInstalled
### Parameters
#### Query Parameters
- **applicationBundleId** (string) - Required - The bundle ID of the application to check.
### Response
#### Success Response (200)
- **status** (boolean) - Returns true if the application is installed, otherwise returns false.
#### Response Example
```json
{
"status": true
}
```
```
--------------------------------
### logWindow.init
Source: https://docs.trollautoscript.com/docs/%E6%97%A5%E5%BF%97%E7%AA%97%E5%8F%A3%E6%A8%A1%E5%9D%97/%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%97%A5%E5%BF%97%E7%AA%97%E5%8F%A3%2BlogWindow.init%2B%2B12ea4400-dde8-4423-9035-af70d35255ed
Initializes and displays a log window at specified screen coordinates with optional styling parameters.
```APIDOC
## logWindow.init
### Description
Creates a log window and displays it immediately on the screen.
### Parameters
- **屏幕横坐标** (数值型) - Required - The X coordinate on the screen.
- **屏幕纵坐标** (数值型) - Required - The Y coordinate on the screen.
- **宽度** (数值型) - Optional - Width of the window (Default: 500px).
- **高度** (数值型) - Optional - Height of the window (Default: 35px).
- **背景透明度** (数值型) - Optional - Transparency level, range 0.1 - 1.0 (Default: 0.5).
- **背景颜色** (整数型) - Optional - Background color in hex (Default: 0x000000).
- **字体颜色** (整数型) - Optional - Font color in hex (Default: 0x00ff00).
- **字体尺寸** (整数型) - Optional - Font size (Default: 12).
### Returns
- **日志窗口对象** (Object) - The initialized log window object.
### Request Example
local lw = logWindow.init(100, 100)
```
--------------------------------
### Train YOLO11 on macOS with Metal GPU
Source: https://docs.trollautoscript.com/docs/coreML%E6%A8%A1%E5%9D%97/%E5%A6%82%E4%BD%95%E8%AE%AD%E7%BB%83%2Bc4cf1f78-8daa-4325-8f1e-d6358ba31002
Ensure Python 3.10 is available. Install the ultralytics package and PyTorch. Then, execute the training command, specifying 'mps' as the device to utilize Metal Performance Shaders for acceleration.
```bash
# 这里假设你已经有 Python 3.10 环境,没有请自行创建(本人仅用 Python 3.10 环境测试,更高版本不确定是否可行)
# 先安装 ultralytics,如果已安装则跳过这一步
pip install ultralytics
# 如果确认安装过了支持 CUDA 的 torch 库则跳过这一步
pip install torch torchvision torchaudio
yolo train model=yolo11m.pt data=COCO.yml epochs=300 imgsz=640 device=mps # 使用 Metal 着色器对加速训练
```
--------------------------------
### webView.init - Create WebView
Source: https://docs.trollautoscript.com/docs/webView%E6%A8%A1%E5%9D%97/%E5%88%9B%E5%BB%BAwebView%E8%A7%86%E5%9B%BE%2BwebView.init%2B%2B2ec42f5d-deaf-49cc-9dfa-da6fa1647984
Initializes and displays a web view on the screen. You can specify its position, dimensions, content (HTML or URL), and appearance properties.
```APIDOC
## POST /websites/trollautoscript/webView.init
### Description
Creates and immediately displays a webView on the screen. This function allows for detailed customization of the web view's properties.
### Method
POST
### Endpoint
/websites/trollautoscript/webView.init
### Parameters
#### Request Body
- **x** (integer) - Required - The x-coordinate on the screen.
- **y** (integer) - Required - The y-coordinate on the screen.
- **width** (integer) - Required - The width of the web view.
- **height** (integer) - Required - The height of the web view.
- **html** (string) - Optional - The HTML content to display. Must be provided if 'url' is not.
- **url** (string) - Optional - The URL to load. Must be provided if 'html' is not. Takes precedence over 'html'.
- **alpha** (integer) - Optional - Transparency level (0-100). Defaults to 100.
- **rotate** (integer) - Optional - Rotation angle in degrees. 90 for right, -90 for left. Defaults to 0.
- **radius** (integer) - Optional - Corner radius. Defaults to 0.
- **hit** (boolean) - Optional - Whether the web view is draggable. Defaults to true.
- **userInteractionEnabled** (boolean) - Optional - Whether the web view is interactive. Defaults to true.
### Request Example
```json
{
"x": 300,
"y": 300,
"width": 800,
"height": 1000,
"html": "Hello World
",
"url": "https://example.com",
"alpha": 100,
"rotate": 0,
"radius": 5,
"hit": true,
"userInteractionEnabled": true
}
```
### Response
#### Success Response (200)
- **webViewObject** (object) - The created web view object.
#### Response Example
```json
{
"webViewObject": { /* ... web view object details ... */ }
}
```
```
--------------------------------
### Get Application Group Info
Source: https://docs.trollautoscript.com/docs/%E5%BA%94%E7%94%A8%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E5%88%86%E7%BB%84%E4%BF%A1%E6%81%AF%2Bapp.groupInfo%2B%2B6cf7d0f1-3dea-4eea-8a56-110ada865a56
Use this function to get group information for an application. Some apps store data within paths in the group information.
```lua
分组信息 = app.groupInfo(应用程序bundleId)
```
```lua
local info = app.groupInfo("com.nssurge.inc.surge-ios")
print(info)
```
--------------------------------
### Create VPN Configuration
Source: https://docs.trollautoscript.com/docs/vpn%E6%A8%A1%E5%9D%97/%E5%88%9B%E5%BB%BAVPN%2Bvpn.create%2B%2B04fdead1-635b-4b09-9ce9-b5a6fb939a6f
Establishes a new VPN configuration using the specified server parameters and authentication credentials.
```lua
if vpn.create("随便起个名字","192.168.100.2" , "username", "password", "suibianzhenggemimayo" ,1 ) then
print("创建VPN 成功")
end
```
--------------------------------
### Get Instance Class Name (:className)
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97new/className
Use this function to get the instance class name of a node object. Requires version 2.3.0 or higher. Returns nil on failure.
```lua
类名 = obj:className()
```
--------------------------------
### 获取应用安装路径示例
Source: https://docs.trollautoscript.com/docs/%E5%BA%94%E7%94%A8%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E5%AE%89%E8%A3%85%E8%B7%AF%E5%BE%84%2Bapp.installPath%2B%2Bf570a5c4-1d95-4f5c-aeac-999dceda495b
使用 app.installPath 获取抖音极速版的安装路径并打印。
```lua
print(string.format("应用的安装路径是:%s" ,app.installPath("com.ss.iphone.ugc.aweme.lite")))
```
--------------------------------
### Get Node Information from Coordinates
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97new/forPoint
Use this function to get node information at a specific coordinate. Ensure the node exists before attempting to access its info. This method is available in versions 2.3.0 and above.
```lua
local node = nodeView.forPoint(1036, 1220) -- 获取节点信息
if (node) then
enumerationInfo(node:info()) -- 绘制节点信息 (此函数已在 前面文档实现 这里不在展示, )
end
sys.msleep(10000) -- 延迟等待 10000毫秒后结束脚本
```
--------------------------------
### 获取设备所有网卡MAC地址
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E8%AE%BE%E5%A4%87%E6%89%80%E6%9C%89%E7%BD%91%E5%8D%A1MAC%2Bdevice.interMAC%2B%2B7eaa5f48-c00d-48ad-a01b-822cf7538a3e
调用 device.interMAC() 函数以数组形式返回所有网卡的 MAC 地址。
```Lua
device.interMAC()
```
```Lua
print(device.interMAC()) --打印这个表
```
--------------------------------
### Get Rectangle Properties of a Node
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97new/frame
Use the :frame() function to get the rectangular properties of a node object. This method requires version 2.3.0 or higher. It returns an array of rectangles on success and nil on failure.
```lua
矩形 = obj:frame()
```
```lua
local node = nodeView.matchForMainWindow(function (info) --匹配节点信息 label==点赞 class==AWEFeedVideoButton 此函数返回节点对象数组 数组型
return info.label == "点赞" and info.class == "AWEFeedVideoButton"
end ,true) --第二个参数为 true 时 返回 对象数组
print(node[1]:frame()) --打印出第一个节点矩形
```
--------------------------------
### GET device.name
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E8%AE%BE%E5%A4%87%E5%90%8D%2Bdevice.name%2B%2B9c5ffff1-ec42-4a4c-b901-24a06121b8dc
Retrieves the name of the current device.
```APIDOC
## GET device.name
### Description
Retrieves the name of the current device running the script.
### Method
GET
### Endpoint
device.name()
### Response
- **name** (string) - The name of the current device.
### Response Example
```lua
print(string.format("当前设备名称是: %s" ,device.name()))
```
```
--------------------------------
### vpn.create
Source: https://docs.trollautoscript.com/docs/vpn%E6%A8%A1%E5%9D%97/%E5%88%9B%E5%BB%BAVPN%2Bvpn.create%2B%2B04fdead1-635b-4b09-9ce9-b5a6fb939a6f
Creates a new VPN configuration with the specified server details and authentication credentials.
```APIDOC
## POST vpn.create
### Description
Creates a new VPN configuration entry in the system.
### Method
POST
### Endpoint
vpn.create
### Parameters
#### Request Body
- **配置名称** (文本型) - Required - The name of the VPN configuration.
- **服务器地址** (文本型) - Required - The IP address or hostname of the VPN server.
- **用户名** (文本型) - Required - The username for authentication.
- **密码** (文本型) - Required - The password for authentication.
- **秘钥** (文本型) - Required - The pre-shared key or secret.
- **vpn类型** (整数型) - Optional - The type of VPN. 1 for L2TP (default), otherwise IPsec.
### Response
#### Success Response (200)
- **创建是否成功** (布尔型) - Returns true if the configuration was created successfully, false otherwise.
### Request Example
```
vpn.create("MyVPN", "192.168.100.2", "username", "password", "secret", 1)
```
```
--------------------------------
### Log Window Initialization Function Signature
Source: https://docs.trollautoscript.com/docs/%E6%97%A5%E5%BF%97%E7%AA%97%E5%8F%A3%E6%A8%A1%E5%9D%97/%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%97%A5%E5%BF%97%E7%AA%97%E5%8F%A3%2BlogWindow.init%2B%2B12ea4400-dde8-4423-9035-af70d35255ed
Defines the `logWindow.init` function signature, including required and optional parameters for screen position, dimensions, and appearance.
```plaintext
日志窗口对象 = logWindow.init(屏幕横坐标,屏幕纵坐标 [宽度,高度,背景透明度,背景颜色,字体颜色 ,字体尺寸])
```
--------------------------------
### GET device.currentSSID
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/currentSSID
Retrieves the SSID of the currently connected Wi-Fi network.
```APIDOC
## GET device.currentSSID
### Description
Retrieves the SSID (Service Set Identifier) of the Wi-Fi network currently connected to the device.
### Method
Function Call
### Endpoint
device.currentSSID()
### Response
- **SSID** (string) - The SSID of the currently connected Wi-Fi network.
### Request Example
```lua
print(string.format("当前设备连接的wifi名称是: %s" ,device.currentSSID()))
```
```
--------------------------------
### GET device.bluetoothMac
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E8%AE%BE%E5%A4%87%E8%93%9D%E7%89%99MAC%2Bdevice.bluetoothMac%2B%2B43f8a41f-4b0d-45c3-81fa-96460d96d52d
Retrieves the Bluetooth MAC address of the current device.
```APIDOC
## GET device.bluetoothMac
### Description
Retrieves the Bluetooth MAC address of the current device.
### Method
GET
### Endpoint
device.bluetoothMac()
### Response
#### Success Response (200)
- **mac** (string) - The Bluetooth MAC address of the device.
### Request Example
```lua
device.bluetoothMac()
```
### Response Example
```json
"00:1A:7D:DA:71:13"
```
```
--------------------------------
### GET sys.mtime
Source: https://docs.trollautoscript.com/docs/%E7%B3%BB%E7%BB%9F%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E6%AF%AB%E7%A7%92%E7%BA%A7%E6%97%B6%E9%97%B4%E6%88%B3%2Bsys.mtime%2B%2B7404f72e-cb1e-40cf-aea1-37cea7232551
Retrieves the current system time as a millisecond-level timestamp.
```APIDOC
## GET sys.mtime
### Description
Retrieves the current system time as a millisecond-level timestamp.
### Method
GET
### Endpoint
sys.mtime()
### Response
#### Success Response (200)
- **时间戳** (Integer) - The current time in milliseconds.
### Request Example
local time = sys.mtime()
```
--------------------------------
### 使用 nodeView.forAddres 获取并处理节点
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97new/forAddres
演示了如何通过坐标获取节点,提取其内存地址,并使用 forAddres 重新加载该节点以进行后续操作。
```lua
local node = nodeView.forPoint(1036, 1220) -- 获取节点信息
local addresNode = nodeView.forAddres(node:info().addres) --从内存地址获取节点
if (addresNode) then
enumerationInfo(addresNode:info()) -- 绘制节点信息 (此函数已在 前面文档实现 这里不在展示, )
end
sys.msleep(10000) -- 延迟等待 10000毫秒后结束脚本
```
--------------------------------
### 检测应用程序运行状态
Source: https://docs.trollautoscript.com/docs/%E5%BA%94%E7%94%A8%E6%A8%A1%E5%9D%97/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E6%98%AF%E5%90%A6%E6%AD%A3%E5%9C%A8%E8%BF%90%E8%A1%8C%2Bapp.isRuning%2B%2B1f9b5071-a142-4450-b525-7b8897c06180
使用 app.isRuning 函数检查特定 bundleId 的应用是否正在运行。
```lua
运行状态 = app.isRuning()
```
```lua
local res = app.isRuning("com.ss.iphone.ugc.aweme.lite")
if res then
print("APP 正在运行中")
else
print("APP 未运行")
end
```
--------------------------------
### Get Device Serial Number
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E8%AE%BE%E5%A4%87%E5%BA%8F%E5%88%97%E5%8F%B7%2Bdevice.serialNumber%2B%2B6a40462d-7ba7-446b-8fde-766115596590
Retrieves the serial number of the current device.
```APIDOC
## GET /device/serialNumber
### Description
Retrieves the serial number of the current device.
### Method
GET
### Endpoint
/device/serialNumber
### Parameters
#### Query Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **serialNumber** (string) - The serial number of the current device.
#### Response Example
{
"serialNumber": "ABC123XYZ789"
}
```
--------------------------------
### 设置设备背光亮度
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/%E8%AE%BE%E7%BD%AE%E8%83%8C%E5%85%89%E4%BA%AE%E5%BA%A6%2Bdevice.setBacklightLevel%2B%2B9a5403f5-0ac7-4e17-96b2-870141b0fcef
通过传入 0.0 到 1.0 之间的浮点数来设置屏幕亮度。此函数需要 2.1.6 或更高版本。
```Lua
device.setBacklightLevel(1.0) --设置最大亮度
device.setBacklightLevel(0.0) --设置最小亮度
```
--------------------------------
### Get Device UDID
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E8%AE%BE%E5%A4%87udid%2Bdevice.udid%2B%2Bfa11508d-a4cb-4bae-b613-56ffc9bd1715
Retrieves the unique identifier (UDID) of the current device.
```APIDOC
## GET /device/udid
### Description
Retrieves the unique identifier (UDID) of the current device.
### Method
GET
### Endpoint
/device/udid
### Parameters
None
### Request Body
None
### Response
#### Success Response (200)
- **udid** (string) - The unique identifier of the device.
#### Response Example
```json
{
"udid": "a1b2c3d4-e5f6-7890-1234-567890abcdef"
}
```
```
--------------------------------
### Get Node Information:OnTap()
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97/%E8%A7%A6%E6%91%B8%E4%B8%80%E6%AC%A1%E8%8A%82%E7%82%B9%2BOnTap%2B%2B16971656-152b-4ed6-b70e-632d82dfb6e7
Retrieves information about the :OnTap function for a node.
```lua
节点信息:OnTap()
```
--------------------------------
### GET :GetSuperNode
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E7%88%B6%E8%8A%82%E7%82%B9%2BGetSuperNode%2B%2B18ff2611-9af6-4337-bb03-6d73e7852e9a
Retrieves the parent node information for a given node object.
```APIDOC
## GetSuperNode
### Description
Retrieves the parent node information of the current node.
### Method
Function Call
### Returns
- **节点信息** (Array) - An array containing the information of the parent node.
### Request Example
```lua
local node = require("nodeLua")
local nodeInfo = node.byLable('猜你想搜,标题' ,'LynxTextView')
if (nodeInfo) then
print(nodeInfo[1]:GetSuperNode())
end
```
```
--------------------------------
### 启动应用程序示例
Source: https://docs.trollautoscript.com/docs/%E5%BA%94%E7%94%A8%E6%A8%A1%E5%9D%97/%E8%BF%90%E8%A1%8C%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%2Bapp.run%2B%2B956cd505-51a8-487c-9cec-3b948b16343f
使用 app.run 启动抖音极速版并进行简单的断言检查。
```lua
local res = app.run("com.ss.iphone.ugc.aweme.lite")
sys.msleep(1000)
assert(res ,"app启动失败.")
```
--------------------------------
### GET node.info()
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E5%89%8D%E5%8F%B0%E5%BA%94%E7%94%A8%E7%9A%84%E8%8A%82%E7%82%B9%E4%BF%A1%E6%81%AF%2Bnode.info%2B%2Bbae5301e-0113-4836-814d-38cfac8c88c6
Retrieves an array of node information for the current foreground application.
```APIDOC
## GET node.info()
### Description
Retrieves the node information for the current foreground application. Note that this function is restricted to applications installed from the Apple Store.
### Method
Function Call
### Returns
- **node_array** (Array) - An array containing all node information for the current foreground application.
### Request Example
```lua
local node = require("nodeLua")
local info = node.info()
print(info)
```
### Response
- **Success**: Returns an array of node information.
- **Failure**: Returns nil.
```
--------------------------------
### GET sys.availableMemory
Source: https://docs.trollautoscript.com/docs/%E7%B3%BB%E7%BB%9F%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E5%BD%93%E5%89%8D%E7%B3%BB%E7%BB%9F%E5%89%A9%E4%BD%99%E5%86%85%E5%AD%98%2Bsys.availableMemory%2B%2Bc5c8aaad-3ac4-4c0c-b248-f72f0652e7b0
Retrieves the current amount of available system memory in megabytes.
```APIDOC
## GET sys.availableMemory
### Description
Retrieves the current device system remaining available memory.
### Method
GET
### Endpoint
sys.availableMemory()
### Response
- **剩余内存** (number) - The amount of remaining memory in megabytes.
### Response Example
```
print(string.format("当前系统未使用的内存:%f mb",sys.availableMemory()))
```
```
--------------------------------
### GET file.getLines
Source: https://docs.trollautoscript.com/docs/%E6%96%87%E4%BB%B6%E6%A8%A1%E5%9D%97/%E8%8E%B7%E5%8F%96%E6%96%87%E4%BB%B6%E7%9A%84%E6%89%80%E6%9C%89%E8%A1%8C%E5%86%85%E5%AE%B9%2Bfile.getLines%2B%2B1dd92bd3-68d2-4cd8-b9b7-0d9a8e83771e
Retrieves all lines from a specified file path and returns them as an array.
```APIDOC
## GET file.getLines
### Description
Retrieves all lines from a specified file path and returns them as an array.
### Parameters
#### Path Parameters
- **文件路径** (文本型) - Required - The path to the file to be read.
### Response
#### Success Response
- **内容数组** (数组型) - An array containing all lines of the file.
### Request Example
```lua
local result = file.getLines("/var/mobile/Media/1.txt")
```
```
--------------------------------
### app.run
Source: https://docs.trollautoscript.com/docs/%E5%BA%94%E7%94%A8%E6%A8%A1%E5%9D%97/%E8%BF%90%E8%A1%8C%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%2Bapp.run%2B%2B956cd505-51a8-487c-9cec-3b948b16343f
Launches an application based on its bundle ID. Note: Usage in Troll environments should be avoided.
```APIDOC
## app.run
### Description
Launches an application using its bundle ID. It is recommended to avoid using this function in Troll environments.
### Parameters
- **应用程序bundelId** (文本型) - Required - The bundle ID of the application to launch.
### Returns
- **运行结果** (布尔型) - Returns true if successful, false if failed.
### Request Example
local res = app.run("com.ss.iphone.ugc.aweme.lite")
sys.msleep(1000)
assert(res ,"app启动失败.")
```
--------------------------------
### Screen Drawing Module Initialization
Source: https://docs.trollautoscript.com/docs/%E5%B1%8F%E5%B9%95%E7%BB%98%E5%88%B6%E6%A8%A1%E5%9D%97
Initializes the screen drawing module.
```APIDOC
## POST screenDraw.init
### Description
Initializes the screen drawing module.
### Method
POST
### Endpoint
/websites/trollautoscript/screenDraw.init
### Parameters
#### Query Parameters
None
#### Request Body
None
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the initialization.
#### Response Example
{
"status": "initialized"
}
```
--------------------------------
### Screen Information Retrieval
Source: https://docs.trollautoscript.com/docs/%E5%B1%8F%E5%B9%95%E6%A8%A1%E5%9D%97
Functions to get screen dimensions and color information.
```APIDOC
## GET /screen/size
### Description
Retrieves the current screen dimensions.
### Method
GET
### Endpoint
/screen/size
## GET /screen/getColor
### Description
Gets the color value of a specific point on the screen.
### Method
GET
### Endpoint
/screen/getColor
### Query Parameters
- **x** (integer) - Required - The x-coordinate of the point.
- **y** (integer) - Required - The y-coordinate of the point.
## GET /screen/isColors
### Description
Checks if multiple points on the screen have specific color values.
### Method
GET
### Endpoint
/screen/isColors
### Query Parameters
- **points** (array of objects) - Required - An array of points, each with x, y, and color properties.
- **x** (integer) - Required - The x-coordinate.
- **y** (integer) - Required - The y-coordinate.
- **color** (string) - Required - The expected color value.
## GET /screen/getColorRGB
### Description
Gets the RGB color value of a specific point on the screen.
### Method
GET
### Endpoint
/screen/getColorRGB
### Query Parameters
- **x** (integer) - Required - The x-coordinate of the point.
- **y** (integer) - Required - The y-coordinate of the point.
```
--------------------------------
### Simulate a Screen Tap with All Parameters
Source: https://docs.trollautoscript.com/docs/%E6%A8%A1%E6%8B%9F%E8%A7%A6%E6%91%B8%E6%A8%A1%E5%9D%97/%E8%A7%A6%E6%91%B8%E4%B8%80%E6%AC%A1%E5%B1%8F%E5%B9%95%2Btouch.tap%2B%2Bf84f027d-318d-4fce-9fe8-9d89fb1abdc4
Simulate a screen tap using all available parameters: coordinates, lift time, pressure, and touch radius level. The touch radius level must be an even number.
```lua
touch.tap(100,100 ,50 ,3 , 4)
```
--------------------------------
### Disable Wi-Fi usage example
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/%E5%81%9C%E7%94%A8WIFI%2Bdevice.turnOffWiFi%2B%2B33189a76-e754-4cbd-ae15-2a8d7364f228
Checks if Wi-Fi is enabled before calling the function to turn it off.
```lua
if device.isWiFiEnabled() then
print("wifi 已启用 停用它")
device.turnOffWiFi()
end
```
--------------------------------
### Select VPN Configuration by Name
Source: https://docs.trollautoscript.com/docs/vpn%E6%A8%A1%E5%9D%97/%E9%80%89%E4%B8%AD%E4%B8%80%E4%B8%AAVPN%2Bvpn.select%2B%2B83b29335-be30-4349-9460-5f7419cf759e
Use this function to select an existing VPN configuration. Provide the exact name of the configuration you wish to activate.
```script
vpn.select("随便起个名字") --选中配置名称为 "随便起个名字" 的VPN 配置
```
--------------------------------
### 匹配节点并获取属性示例
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97new/text
演示如何通过 matchForMainWindow 匹配特定节点并调用其方法。
```lua
local node = nodeView.matchForMainWindow(function (info) --匹配节点信息 label==点赞 class==AWEFeedVideoButton 此函数返回节点对象数组 数组型
return info.label == "点赞" and info.class == "AWEFeedVideoButton"
end ,true) --第二个参数为 true 时 返回 对象数组
print(node[1]:frame()) --打印出第一个节点矩形
```
--------------------------------
### 关闭飞行模式函数定义
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/%E5%85%B3%E9%97%AD%E9%A3%9E%E8%A1%8C%E6%A8%A1%E5%BC%8F%2Bdevice.turnOffAirplane%2B%2Bf567a683-542c-47c5-af22-a5f98196a437
此函数用于关闭设备的飞行模式,要求版本在 2.1.6 以上。
```lua
device.turnOffAirplane()
```
--------------------------------
### Get VPN Connection State
Source: https://docs.trollautoscript.com/docs/vpn%E6%A8%A1%E5%9D%97/%E5%BD%93%E5%89%8DVPN%E7%9A%84%E8%BF%9E%E6%8E%A5%E7%8A%B6%E6%80%81%2Bvpn.connectState%2B%2B61f7bbdb-3ebc-427a-9cbd-cd3c45f8b9cc
Retrieves the connection status of the current VPN on the device.
```APIDOC
## GET /vpn/connectState
### Description
Gets the connection status of the current VPN on the device.
### Method
GET
### Endpoint
/vpn/connectState
### Parameters
None
### Request Body
None
### Response
#### Success Response (200)
- **connection_state** (string) - The connection status of the VPN.
#### Response Example
```json
{
"connection_state": "Connected"
}
```
### Example Usage
```lua
local status = vpn.connectState()
print(string.format("Current VPN Connection State is: %s", status))
```
```
--------------------------------
### GET device.isAirplaneEnabled
Source: https://docs.trollautoscript.com/docs/%E8%AE%BE%E5%A4%87%E6%A8%A1%E5%9D%97/%E9%A3%9E%E8%A1%8C%E6%A8%A1%E5%BC%8F%E6%98%AF%E5%90%A6%E5%90%AF%E7%94%A8%2Bdevice.isAirplaneEnabled%2B%2B893bda30-adb6-4e5f-9a84-c2b05ee7e22a
Checks whether the device's airplane mode is currently enabled.
```APIDOC
## GET device.isAirplaneEnabled
### Description
Used to determine if airplane mode is enabled on the device. Requires version 2.1.6 or higher.
### Method
GET
### Endpoint
device.isAirplaneEnabled()
### Response
#### Success Response (200)
- **enabled** (boolean) - Returns true if airplane mode is enabled, otherwise false.
### Request Example
```lua
if device.isAirplaneEnabled() then
print("飞行模式已经启用")
else
print("飞行模式已关闭")
end
```
```
--------------------------------
### vpn.select(configuration_name)
Source: https://docs.trollautoscript.com/docs/vpn%E6%A8%A1%E5%9D%97/%E9%80%89%E4%B8%AD%E4%B8%80%E4%B8%AAVPN%2Bvpn.select%2B%2B83b29335-be30-4349-9460-5f7419cf759e
Selects an existing VPN configuration.
```APIDOC
## vpn.select(configuration_name)
### Description
Used to select an existing configuration.
### Method
Not applicable (function call)
### Endpoint
Not applicable (function call)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```lua
vpn.select("MyVPNConfig")
```
### Response
#### Success Response (Boolean)
- **result** (boolean) - True if the configuration was selected successfully, false otherwise.
#### Response Example
```json
true
```
```
--------------------------------
### GET nodeView.infoForMainWindow
Source: https://docs.trollautoscript.com/docs/%E8%8A%82%E7%82%B9%E6%A8%A1%E5%9D%97new/infoForMainWindow
Retrieves the node information for the current foreground application's KeyWindow.
```APIDOC
## GET nodeView.infoForMainWindow
### Description
Returns the node information of the current foreground app's KeyWindow as a JSON string. This method is available in version 2.3.0 and above.
### Method
GET
### Response
#### Success Response (200)
- **节点信息** (string) - A JSON string containing the node information of the KeyWindow.
### Request Example
```lua
local info = nodeView.infoForMainWindow()
```
### Response Example
```json
[
{
"frame": {"x": 0, "y": 0, "width": 1080, "height": 1920},
"text": "Example Node",
"subviews": []
}
]
```
```