UNPKG

@ahmic/autoit-js

Version:
62 lines (61 loc) 2.98 kB
import { IPoint } from './@types'; /** * Searchs for a given pixel within the specified region. * * The actual `AU3_PixelSearch` function from AutoIt appears to be broken so it has been reimplemented here * using Windows GDI32 and User32 libraries. * * @see https://www.autoitscript.com/forum/topic/210967-autoitx-au3_pixelsearch-access-violation/ * @see https://www.autoitscript.com/forum/topic/210967-autoitx-au3_pixelsearch-access-violation/#comment-1525551 * * @param left The X coordinate of the left edge of the rectangle. * @param top The Y coordinate of the top edge of the rectangle. * @param right The X coordinate of the right edge of the rectangle. * @param bottom The Y coordinate of the bottom edge of the rectangle. * @param color The color to search for, in `0xRRGGBB` format. * @param shadeVariation The allowed variation in color shades (default is 0). * @param step The step value for the search (default is 1). * * @returns An {@linkcode IPoint} object with the coordinates of the found pixel. If the pixel is not found, * returns a point with coordinates (-1, -1). * * @example * ```typescript * import { PixelSearchSync } from '@ahmic/autoit-js'; * * const result = PixelSearchSync(0, 0, 100, 100, 0xFF0000); * * console.log(result); // Output: { x: 50, y: 50 } * ``` */ export declare function PixelSearchSync(left: number, top: number, right: number, bottom: number, color: number, shadeVariation?: number, step?: number): IPoint; /** * Searchs for a given pixel within the specified region. * * The actual `AU3_PixelSearch` function from AutoIt appears to be broken so it has been reimplemented here * using Windows GDI32 and User32 libraries. * * @see https://www.autoitscript.com/forum/topic/210967-autoitx-au3_pixelsearch-access-violation/ * @see https://www.autoitscript.com/forum/topic/210967-autoitx-au3_pixelsearch-access-violation/#comment-1525551 * * @param left The X coordinate of the left edge of the rectangle. * @param top The Y coordinate of the top edge of the rectangle. * @param right The X coordinate of the right edge of the rectangle. * @param bottom The Y coordinate of the bottom edge of the rectangle. * @param color The color to search for, in `0xRRGGBB` format. * @param shadeVariation The allowed variation in color shades (default is 0). * @param step The step value for the search (default is 1). * * @returns A promise that resolves to an {@linkcode IPoint} object with the coordinates of the found pixel. * If the pixel is not found, the promise resolves to a point with coordinates (-1, -1). * * @example * ```typescript * import { PixelSearch } from '@ahmic/autoit-js'; * * const result = await PixelSearch(0, 0, 100, 100, 0xFF0000); * * console.log(result); // Output: { x: 50, y: 50 } * ``` */ export declare function PixelSearch(left: number, top: number, right: number, bottom: number, color: number, shadeVariation?: number, step?: number): Promise<IPoint>;