script

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandSchema added in v0.3.0

type CommandSchema struct {
	// Input command - inject keyboard input
	Input *InputCmd `json:"input,omitempty" jsonschema:"oneof_required=input,description=Inject keyboard input"`

	// Mouse command - inject mouse input
	Mouse *MouseCmd `json:"mouse,omitempty" jsonschema:"oneof_required=mouse,description=Inject mouse input"`

	// Wheel command - inject wheel/scroll input
	Wheel *WheelCmd `json:"wheel,omitempty" jsonschema:"oneof_required=wheel,description=Inject wheel/scroll input"`

	// Screenshot command - capture game screenshot
	Screenshot *ScreenshotCmd `json:"screenshot,omitempty" jsonschema:"oneof_required=screenshot,description=Capture game screenshot"`

	// Delay command - pause execution
	Delay *DelayCmd `json:"delay,omitempty" jsonschema:"oneof_required=delay,description=Pause execution for a duration"`

	// Custom command - execute a registered custom command
	Custom *CustomCmd `json:"custom,omitempty" jsonschema:"oneof_required=custom,description=Execute a registered custom command"`

	// Repeat command - repeat a block of commands
	Repeat *RepeatSchema `json:"repeat,omitempty" jsonschema:"oneof_required=repeat,description=Repeat a block of commands"`
}

CommandSchema represents a command in the script format for schema generation. Only one field should be set at a time.

type CommandWrapper added in v0.3.0

type CommandWrapper interface {
	// contains filtered or unexported methods
}

CommandWrapper is the interface for all command types.

type CustomCmd added in v0.3.0

type CustomCmd struct {
	Name    string `json:"name" jsonschema:"description=Name of the registered custom command"`
	Request string `json:"request,omitempty" jsonschema:"description=Optional request data to pass to the custom command"`
}

CustomCmd represents a custom command.

type DelayCmd

type DelayCmd struct {
	Ms int64 `json:"ms" jsonschema:"minimum=0,description=Milliseconds to wait"`
}

DelayCmd represents a delay command.

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor executes a script.

func NewExecutor

func NewExecutor(s *Script) *Executor

NewExecutor creates a new script executor.

func (*Executor) Execute

func (e *Executor) Execute() (int, error)

Execute runs the script.

func (*Executor) SetCustomFunc added in v0.3.0

func (e *Executor) SetCustomFunc(f func(name, request string) error)

SetCustomFunc sets the function to call for custom commands.

func (*Executor) SetInputFunc

func (e *Executor) SetInputFunc(f func(key, action string, durationTicks int64, async bool) error)

SetInputFunc sets the function to call for input commands.

func (*Executor) SetMouseFunc

func (e *Executor) SetMouseFunc(f func(action string, x, y int, button string, durationTicks int64, async bool) error)

SetMouseFunc sets the function to call for mouse commands.

func (*Executor) SetScreenshotFunc

func (e *Executor) SetScreenshotFunc(f func(output string, b64, async bool) error)

SetScreenshotFunc sets the function to call for screenshot commands.

func (*Executor) SetWheelFunc

func (e *Executor) SetWheelFunc(f func(x, y float64, async bool) error)

SetWheelFunc sets the function to call for wheel commands.

type InputCmd

type InputCmd struct {
	Action        string `json:"action" jsonschema:"enum=press,enum=release,enum=hold,description=Action to perform"`
	Key           string `json:"key" jsonschema:"description=Key name (use 'autoebiten keys' to list all)"`
	DurationTicks int64  `json:"duration_ticks" jsonschema:"default=6,description=Duration in game ticks for hold action"`
	Async         bool   `json:"async" jsonschema:"default=false,description=Return immediately without waiting"`
}

InputCmd represents an input command.

type MouseCmd

type MouseCmd struct {
	Action        string `` /* 154-byte string literal not displayed */
	X             int    `json:"x" jsonschema:"default=0,description=X coordinate"`
	Y             int    `json:"y" jsonschema:"default=0,description=Y coordinate"`
	Button        string `json:"button" jsonschema:"description=Mouse button (use 'autoebiten mouse_buttons' to list all)"`
	DurationTicks int64  `json:"duration_ticks" jsonschema:"default=6,description=Duration in game ticks for hold action"`
	Async         bool   `json:"async" jsonschema:"default=false,description=Return immediately without waiting"`
}

MouseCmd represents a mouse command.

type RepeatCmd

type RepeatCmd struct {
	Times    int              `json:"times"`
	Commands []CommandWrapper `json:"commands"`
}

RepeatCmd represents a repeat block.

type RepeatSchema added in v0.3.0

type RepeatSchema struct {
	Times    int             `json:"times" jsonschema:"minimum=1,description=Number of times to repeat"`
	Commands []CommandSchema `json:"commands" jsonschema:"description=Commands to repeat"`
}

RepeatSchema represents a repeat block for schema generation.

type ScreenshotCmd

type ScreenshotCmd struct {
	Output string `json:"output" jsonschema:"description=Output file path (optional, auto-generated if not provided)"`
	Base64 bool   `` /* 131-byte string literal not displayed */
	Async  bool   `json:"async" jsonschema:"default=false,description=Return immediately without waiting"`
}

ScreenshotCmd represents a screenshot command.

type Script

type Script struct {
	Version  string           `json:"version"`
	Commands []CommandWrapper `json:"commands"`
}

Script is the root node of a script.

func Parse

func Parse(path string) (*Script, error)

Parse reads and parses a script file.

func ParseBytes

func ParseBytes(data []byte) (*Script, error)

ParseBytes parses a script from JSONC bytes (JSON with Comments).

func ParseString

func ParseString(s string) (*Script, error)

ParseString parses a script from a JSON string.

func (*Script) UnmarshalJSON added in v0.3.0

func (s *Script) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling for CommandWrapper.

type ScriptSchema added in v0.3.0

type ScriptSchema struct {
	// Schema is the JSON Schema URI for this document
	Schema string `json:"$schema,omitempty" jsonschema:"type=string,format=uri-reference,description=JSON Schema URI for this document"`

	Version string `json:"version" jsonschema:"enum=1.0,description=Script format version"`

	// Commands to execute in order
	Commands []CommandSchema `json:"commands" jsonschema:"description=List of commands to execute in order"`
}

ScriptSchema represents the root script structure for schema generation.

type WheelCmd

type WheelCmd struct {
	X     float64 `json:"x" jsonschema:"default=0,description=Horizontal scroll"`
	Y     float64 `json:"y" jsonschema:"default=0,description=Vertical scroll"`
	Async bool    `json:"async" jsonschema:"default=false,description=Return immediately without waiting"`
}

WheelCmd represents a wheel command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL