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 |
FractionValue | Fraction value. |
IsEmpty | Returns |
Max | Returns |
MaxInside | Returns |
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 |
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 |
ToString() |
Operators
Name | Description |
---|---|
implicit operator Coord(Index) | Creates Coord of Normal or Reverse type. Reverse if the index is from end, like |
implicit operator Coord(int) | Creates Coord of Normal type. |
implicit operator Coord(float) | Creates Coord of Fraction type. |