Skip to content

修正类型定义 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions types/modules/coordinate.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ declare function setScreenMetrics(width: number, height: number): void;
*
* 模拟点击坐标(x, y)大约150毫秒,并返回是否点击成功。只有在点击执行完成后脚本才继续执行。
*/
declare function click(x: number, y: number): void;
declare function click(x: number, y: number): boolean;

/**
* Android7.0以上
*
* 模拟长按坐标(x, y), 并返回是否成功。只有在长按执行完成(大约600毫秒)时脚本才会继续执行。
*/
declare function longClick(x: number, y: number): void;
declare function longClick(x: number, y: number): boolean;

/**
* Android7.0以上
Expand All @@ -28,7 +28,7 @@ declare function longClick(x: number, y: number): void;
*
* 如果按住时间过短,那么会被系统认为是点击;如果时长超过500毫秒,则认为是长按。
*/
declare function press(x: number, y: number, duration: number): void;
declare function press(x: number, y: number, duration: number): boolean;

/**
* 模拟从坐标(x1, y1)滑动到坐标(x2, y2),并返回是否成功。只有滑动操作执行完成时脚本才会继续执行。
Expand Down
16 changes: 8 additions & 8 deletions types/modules/images.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ declare namespace images {
threshold?: number;
}
function clip(image: Image, x: number, y: number, w: number, h: number): Image;
function findColor(image: Image, color: number | string, options: FindColorOptions): Point;
function findColorInRegion(image: Image, color: number | string, x: number, y: number, width?: number, height?: number, threshold?: number): Point;
function findColorEquals(image: Image, color: number | string, x?: number, y?: number, width?: number, height?: number): Point;
function detectsColor(image: Image, color: number | string, x: number, y: number, threshold?: number, algorithm?: 'diff'): Point;
function findColor(image: Image, color: number | string, options: FindColorOptions): Point | null;
function findColorInRegion(image: Image, color: number | string, x: number, y: number, width?: number, height?: number, threshold?: number): Point | null;
function findColorEquals(image: Image, color: number | string, x?: number, y?: number, width?: number, height?: number): Point | null;
function detectsColor(image: Image, color: number | string, x: number, y: number, threshold?: number, algorithm?: 'diff'): Boolean;
interface FindImageOptions {
region?: [number, number] | [number, number, number, number];
threshold?: number;
level?: number;
}
function findImage(image: Image, template: Image, options: FindImageOptions): Point;
function findImageInRegion(image: Image, template: Image, x: number, y: number, width?: number, height?: number, threshold?: number): Point;
function findMultiColors(image: Image, firstColor: number | string, colors: [number, number, number | string][], options?: FindColorOptions): Point;
function findImage(image: Image, template: Image, options: FindImageOptions): Point | null;
function findImageInRegion(image: Image, template: Image, x: number, y: number, width?: number, height?: number, threshold?: number): Point | null;
function findMultiColors(image: Image, firstColor: number | string, colors: [number, number, number | string][], options?: FindColorOptions): Point | null;

function fromBase64(base64: string): Image;
function fromBase64(base64: string): Image | null;
function toBase64(img: Image): string;
}