Show / Hide Table of Contents

Struct Coord

Contains x or y coordinate in screen or some other rectangle that can be specified in various ways: normal, reverse, fraction, center, max. Used for parameters of functions like mouse.move, wnd.Move.

public record struct Coord : IEquatable<Coord>
Remarks

To specify a normal coordinate (the origin is the left or top edge), assign an int value (implicit conversion from int to Coord). To specify a reverse coordinate (the origin is the right or bottom edge), use Coord.Reverse or a "from end" index like ^1. It is towards the left or top edge, unless negative. Or use Coord.Max or Coord.MaxInside. To specify a "fraction of the rectangle" coordinate, use Coord.Fraction or a value of type float like .5f. Or use Coord.Center. The meaning of default(Coord) depends on function where used. Many functions interpret it as center (same as Coord.Center or .5f). Also there are functions to convert Coord to normal coordinates.

Examples
mouse.move(100, 100); //left edge + 100, top edge + 100
mouse.move(Coord.Reverse(100), 100); //right edge - 100, top edge + 100
mouse.move(100, ^100); //left edge + 100, bottom edge - 100
mouse.move(Coord.Fraction(.33), .9f); //left edge + 1/3 of the screen rectangle, top edge + 9/10
mouse.move(Coord.Center, Coord.MaxInside); //x in center (left edge + 1/2), y by the bottom edge inside (Coord.Max would be outside)
mouse.move(Coord.Reverse(-100), 1.1f); //right edge + 100, bottom edge + 0.1 of the rectangle

var w = wnd.find(1, "Untitled - Notepad", "Notepad");
w.Move(.5f, 100, .5f, ^200); //x = center, y = 100, width = half of screen, height = screen height - 200

Namespace: Au.Types
Assembly: Au.dll

Properties

Name Description
Center

Returns Fraction(0.5).

FractionValue

Fraction value.

IsEmpty

Returns true if Type == CoordType.None (no value assigned).

Max

Returns Reverse(0). Same as ^0. This point will be outside of the rectangle. See also Coord.MaxInside.

MaxInside

Returns Reverse(1). Same as ^1. This point will be inside of the rectangle, at the very right or bottom, assuming the rectangle is not empty.

Type

Value type.

Value

Non-fraction value.

Methods

Name Description
Fraction(double)

Creates Coord of Fraction type. Value 0 is the left or top of the rectangle. Value 1.0 is the right or bottom of the rectangle. Values <0 and >=1.0 are outside of the rectangle. Instead can be used implicit conversion from float, for example argument Coord.Fraction(.5) can be replaced with .5f.

Normalize(Coord, Coord, bool, screen, bool, bool)

Returns normal coordinates relative to the primary screen. Converts fractional/reverse coordinates etc.

NormalizeInRange(int, int)

Converts fractional/reverse coordinate to normal coordinate in a range.

NormalizeInRect(Coord, Coord, RECT, bool, bool)

Converts fractional/reverse coordinates to normal coordinates in a rectangle.

NormalizeInWindow(Coord, Coord, wnd, bool, bool)

Returns normal coordinates relative to the client area of a window. Converts fractional/reverse coordinates etc.

Reverse(int)

Creates Coord of Reverse type. Value 0 is at the right or bottom, and does not belong to the rectangle. Positive values are towards left or top. Instead can be use "from end" index, for example argument Coord.Reverse(1) can be replaced with ^1.

ToString()

Operators

Name Description
implicit operator Coord(Index)

Creates Coord of Normal or Reverse type. Reverse if the index is from end, like ^1.

implicit operator Coord(int)

Creates Coord of Normal type.

implicit operator Coord(float)

Creates Coord of Fraction type.