diff --git a/types/modules/coordinate.d.ts b/types/modules/coordinate.d.ts index 712ac1d..6b9ce6c 100644 --- a/types/modules/coordinate.d.ts +++ b/types/modules/coordinate.d.ts @@ -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以上 @@ -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),并返回是否成功。只有滑动操作执行完成时脚本才会继续执行。 diff --git a/types/modules/images.d.ts b/types/modules/images.d.ts index 52c6bdd..aba153e 100644 --- a/types/modules/images.d.ts +++ b/types/modules/images.d.ts @@ -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; }