Selector

Click Offset and Image Matching

WithOffsetX and WithOffsetY shift where a click lands relative to the top-left corner of the matched element - useful when a click must land in a specific spot within a larger element. WithDeltaX and WithDeltaY define the drop offset for drag-and-drop operations. WithImage, WithImageOffsetX, and WithImageOffsetY use OpenCV template matching to find an element by visual appearance rather than by DOM properties - valuable for canvas elements, legacy applications, or any UI that does not expose automation properties.

NOTE

Image-based matching is slower than property-based matching because it requires a screenshot comparison on each attempt. Use it only when no other selector approach is available.

Examples

GPAL Fluent: High-level fluent C# API

//WithImage accepts a file path (string), a GPALFile, or a System.Drawing.Image object. The template image should be a clean crop of the target element at the same screen resolution and zoom level.

// Click 10px right and 5px down from element top-left

var offsetClick = GPAL.Selector

.WithCSS(".chart-area")

.WithOffsetX(10)

.WithOffsetY(5);


// Find and click a button by its visual appearance

var imgBtn = GPAL.Selector

.WithImage("submit-button.png")

.WithImageOffsetX(5)

.WithImageOffsetY(3);

💬 Ask GPAL