npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@oukek/myt

v1.0.5

Published

OukekMyt SDK - A powerful SDK for OukekMyt

Readme

Myt Node SDK

本 SDK 提供了一个简单的接口,通过 Python 后端执行设备操作。

安装

npm install @oukek/myt

使用方法

首先,导入SDK并初始化连接:

import { OukekMyt, connectToSocket, disconnectFromSocket } from '@oukek/myt';

// 首先建立与Python后端的连接
await connectToSocket();

// 创建设备实例
const myt = new OukekMyt('192.168.1.100', 5555, 30000);

// 使用设备
const version = await myt.getSdkVersion();
console.log('SDK版本:', version);

// 在应用退出前断开连接
await disconnectFromSocket();

连接管理

建立连接

async connectToSocket(socketPort?: number): Promise<void>

连接到Python后端服务,可选择指定端口。

断开连接

async disconnectFromSocket(): Promise<void>

关闭与Python后端的连接,会自动关闭所有设备连接。

设备操作

创建设备实例时需要提供设备IP、端口和超时时间:

const myt = new OukekMyt(deviceIp, devicePort, deviceTimeout);

设备连接相关

关闭设备连接

async close(): Promise<boolean>

关闭当前设备连接。

获取SDK版本

async getSdkVersion(): Promise<string>

获取当前SDK的版本号。

检查连接状态

async checkConnectState(): Promise<boolean>

检查设备连接状态。

工作模式设置

设置RPA工作模式

async setRpaWorkMode(mode: number): Promise<boolean>

设置RPA工作模式。

截图相关

压缩截图

async takeCaptrueCompress(type: 0 | 1 = 0, quality: number): Promise<string>

进行压缩截图,type为0表示PNG格式,1表示JPG格式。

截图保存

async screentshot(type: 0 | 1 = 0, quality: number, path: string): Promise<string>

截图并保存到指定路径。

区域截图

async screentshotEx(x1: number, y1: number, x2: number, y2: number, type: 0 | 1, quality: number, path: string): Promise<string>

对指定区域进行截图并保存。

区域压缩截图

async takeCaptrueCompressEx(left: number, top: number, right: number, bottom: number, type: 0 | 1, quality: number): Promise<string>

对指定区域进行压缩截图。

节点操作

导出节点XML

async dumpNodeXml(includeInvisible: 0 | 1 = 1): Promise<string>

导出节点XML,可选择是否包含不可见节点。

扩展导出节点XML

async dumpNodeXmlEx(workMode: number, timeout: number): Promise<string>

使用自定义工作模式和超时时间导出节点XML。

通过类名获取节点

async getNodeByClass(className: string): Promise<any>

通过类名查找节点。

应用操作

打开应用

async openApp(packageName: string): Promise<boolean>

打开指定包名的应用。

停止应用

async stopApp(packageName: string): Promise<boolean>

停止指定包名的应用。

文本输入

发送文本

async sendText(text: string): Promise<boolean>

发送文本内容。

清除文本

async clearText(count: number): Promise<boolean>

清除指定数量的文本。

命令执行

执行命令

async execCmd(cmd: string): Promise<string>

执行指定的命令。

触摸操作

按下触摸

async touchDown(fingerId: number, x: number, y: number): Promise<boolean>

在指定坐标按下触摸。

移动触摸

async touchMove(fingerId: number, x: number, y: number): Promise<boolean>

移动触摸到指定坐标。

抬起触摸

async touchUp(fingerId: number, x: number, y: number): Promise<boolean>

在指定坐标抬起触摸。

点击触摸

async touchClick(fingerId: number, x: number, y: number): Promise<boolean>

在指定坐标进行点击操作。

长按触摸

async longClick(fingerId: number, x: number, y: number, duration: number): Promise<boolean>

在指定坐标进行长按操作。

滑动操作

async swipe(fingerId: number, x1: number, y1: number, x2: number, y2: number, duration: number): Promise<boolean>

从起始坐标滑动到目标坐标。

按键操作

按键按下

async keyPress(keycode: number): Promise<boolean>

按下指定键码的按键。

返回键

async pressBack(): Promise<boolean>

按下返回键。

确认键

async pressEnter(): Promise<boolean>

按下确认键。

主页键

async pressHome(): Promise<boolean>

按下主页键。

最近任务键

async pressRecent(): Promise<boolean>

按下最近任务键。

节点查找方法

通过文本查找节点

async getNodeByText(text: string): Promise<any>

通过文本内容查找节点。

通过文本结尾匹配查找节点

async getNodeByTextMatchEnd(text: string): Promise<any>

通过文本结尾匹配查找节点。

通过文本开头匹配查找节点

async getNodeByTextMatchStart(text: string): Promise<any>

通过文本开头匹配查找节点。

通过包名查找节点

async getNodeByPkg(pkg: string): Promise<any>

通过包名查找节点。

通过ID查找节点

async getNodeById(id: string): Promise<any>

通过ID查找节点。

通过描述查找节点

async getNodeByDesc(desc: string): Promise<any>

通过描述查找节点。

点击操作

点击文本

async clickText(text: string): Promise<boolean>

点击指定文本。

点击文本开头匹配

async clickTextMatchStart(text: string): Promise<boolean>

点击文本开头匹配的内容。

点击类名

async clickClass(className: string): Promise<boolean>

点击指定类名的元素。

点击ID

async clickId(id: string): Promise<boolean>

点击指定ID的元素。

点击描述

async clickDesc(desc: string): Promise<boolean>

点击指定描述的元素。

其他功能

获取显示旋转

async getDisplayRotate(): Promise<number>

获取屏幕旋转状态。

错误处理

SDK在以下情况下可能会抛出错误:

  • 设备未初始化
  • 操作超时
  • Python进程失败
  • 无效的结果类型
  • JSON解析错误

所有错误都会被包装在描述性消息中,指示失败的操作。

注意事项

  • SDK使用Python后端进程执行操作
  • 使用前必须先调用connectToSocket建立Python后端连接
  • 设备初始化是自动的,无需显式调用init方法
  • 所有设备方法都是异步的,需要使用async/await或Promise处理
  • 在应用退出前请调用disconnectFromSocket关闭连接