Skip to content

Feature/445/config interfaces #446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AssertClass } from "./lib/assert.class";
import { ClipboardClass } from "./lib/clipboard.class";
import { KeyboardClass } from "./lib/keyboard.class";
import { MouseClass } from "./lib/mouse.class";
import { KeyboardClass, KeyboardConfig } from "./lib/keyboard.class";
import { MouseClass, MouseConfig } from "./lib/mouse.class";
import { createMovementApi } from "./lib/movement.function";
import { ScreenClass } from "./lib/screen.class";
import { ScreenClass, ScreenConfig } from "./lib/screen.class";
import { LineHelper } from "./lib/util/linehelper.class";
import { createWindowApi } from "./lib/window.function";
import providerRegistry from "./lib/provider/provider-registry.class";
Expand All @@ -13,8 +13,11 @@ export {
AssertClass,
ClipboardClass,
KeyboardClass,
KeyboardConfig,
MouseClass,
MouseConfig,
ScreenClass,
ScreenConfig,
providerRegistry,
};

Expand Down
15 changes: 11 additions & 4 deletions lib/keyboard.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@ const inputIsString = (input: (string | Key)[]): input is string[] => {
return input.every((elem: string | Key) => typeof elem === "string");
};

/**
* Config object for {@link KeyboardClass} class
*/
export interface KeyboardConfig {
/**
* Configures the delay between single key events
*/
autoDelayMs: number;
}

/**
* {@link KeyboardClass} class provides methods to emulate keyboard input
*/
export class KeyboardClass {
/**
* Config object for {@link KeyboardClass} class
*/
public config = {
/**
* Configures the delay between single key events
*/
public config: KeyboardConfig = {
autoDelayMs: 300,
};

Expand Down
27 changes: 16 additions & 11 deletions lib/mouse.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,26 @@ import {
import { ProviderRegistry } from "./provider/provider-registry.class";

/**
* {@link MouseClass} class provides methods to emulate mouse input
* Config object for {@link MouseClass} class
*/
export class MouseClass {
export interface MouseConfig {
/**
* Config object for {@link MouseClass} class
* Configures the delay between single mouse events
*/
public config = {
/**
* Configures the delay between single mouse events
*/
autoDelayMs: 100,
autoDelayMs: number;

/**
* Configures the speed in pixels/second for mouse movement
*/
mouseSpeed: number;
}

/**
* Configures the speed in pixels/second for mouse movement
*/
/**
* {@link MouseClass} class provides methods to emulate mouse input
*/
export class MouseClass {
public config: MouseConfig = {
autoDelayMs: 100,
mouseSpeed: 1000,
};

Expand Down
52 changes: 30 additions & 22 deletions lib/screen.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,43 @@ function validateSearchRegion(search: Region, screen: Region) {
}

/**
* {@link ScreenClass} class provides methods to access screen content of a systems main display
* Config object for {@link ScreenClass} class
*/
export class ScreenClass {
export interface ScreenConfig {
/**
* Config object for {@link ScreenClass} class
* Configures the required matching percentage for template images to be declared as a match
*/
public config = {
/**
* Configures the required matching percentage for template images to be declared as a match
*/
confidence: 0.99,
confidence: number;

/**
* Configure whether to auto highlight all search results or not
*/
autoHighlight: boolean;
/**
* Configure highlighting duration
*/
highlightDurationMs: number;

/**
* Configure opacity of highlight window
*/
highlightOpacity: number;

/**
* Configure whether to auto highlight all search results or not
*/
/**
* Configures the path from which template images are loaded from
*/
resourceDirectory: string;
}

/**
* {@link ScreenClass} class provides methods to access screen content of a systems main display
*/
export class ScreenClass {
public config: ScreenConfig = {
confidence: 0.99,
autoHighlight: false,
/**
* Configure highlighting duration
*/
highlightDurationMs: 500,

/**
* Configure opacity of highlight window
*/
highlightOpacity: 0.25,

/**
* Configures the path from which template images are loaded from
*/
resourceDirectory: cwd(),
};

Expand Down