Class ContinuousAutomation

java.lang.Object
io.github.jspinak.brobot.automationScripts.BaseAutomation
io.github.jspinak.brobot.automationScripts.ContinuousAutomation
All Implemented Interfaces:
AutomationScript

@Component public class ContinuousAutomation extends BaseAutomation
Implements continuous state-based automation that monitors and responds to GUI changes.

ContinuousAutomation provides an event-loop based automation pattern that continuously monitors the GUI for active states and executes appropriate transitions. This implementation is ideal for reactive automation scenarios where the system must respond to unpredictable GUI events or maintain ongoing interaction with an application.

Execution model:

  • Periodic Scanning: Searches for active states at configurable intervals
  • Transition Execution: Runs transitions for any active states found
  • Rest State Support: Naturally pauses at states without transitions
  • Concurrent Safety: Single-threaded executor prevents race conditions

Key features:

  • Automatic state discovery through periodic searches
  • Graceful handling of states with and without transitions
  • Clean shutdown with proper thread termination
  • Error recovery with automatic stop on exceptions
  • Configurable search intervals for performance tuning

Common use cases:

  • Monitoring applications for specific conditions
  • Handling asynchronous popups or notifications
  • Maintaining application state during long-running processes
  • Creating responsive bots that react to GUI events
  • Implementing watchdog functionality

State handling strategy:

  • Active states with transitions trigger state handler execution
  • Active states without transitions serve as rest points
  • Multiple active states are processed sequentially
  • State handler failures are logged but don't stop execution

Performance considerations:

  • Search interval affects responsiveness vs. CPU usage
  • State finder efficiency impacts overall performance
  • Consider search optimization for large state spaces
  • Single-threaded design prevents parallel state handling

In the model-based approach, ContinuousAutomation embodies the reactive automation paradigm where the system continuously adapts to the current GUI state. This pattern is particularly powerful for applications with dynamic behavior, unexpected events, or when human interaction may occur alongside automation.

Since:
1.0
See Also: