ScriptedInput
ConsoleMonster.Input
Input from a script, for tests, demos and recordings: Down Down Space "ad.evotec" Enter. key names as accepts them (Ctrl+K, Shift+Tab, F2, ?); Down*3 repeats a key (at most 10000 times); quoted text ("text" or 'text') types each character; paste:"text" pastes; resize:80x24 resizes; wait:250 pauses (milliseconds); the mouse at zero-based cells: click:12,5, rclick:12,5 (right button), dclick:12,5 (double click), move:12,5, wheel:12,5,-3 (three notches down; positive is up) and drag:12,5,30,5 (press, move cell by cell, release). Reading past the end throws InputClosedException, so a test whose script is too short fails instead of hanging.
Inheritance
- object
- ScriptedInput
Usage
Explore 1 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 1
- Method TestTerminal.Keys
Constructors
Methods
public void Append(string script) #Appends events to the script.
Parameters
- script string
- More script.
public void Dispose() #Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public static IReadOnlyList<InputEvent> ParseEvents(string script) #Parses a script into events (pauses are dropped).
Parameters
- script string
- The script.
public InputEvent? Read(TimeSpan timeout, CancellationToken cancellationToken) #Waits up to timeout for the next event.
Parameters
- timeout System.TimeSpan
- The longest wait; TimeSpan.Zero polls.
- cancellationToken System.Threading.CancellationToken
- Cancels the wait with OperationCanceledException.
Exceptions
InputClosedException– The input ended (end of a script, closed stdin).
public void WaitForOutput(ScreenCapture capture, string text, TimeSpan timeout) #Queues a bounded wait for visible output before subsequently appended input. Reads return timeouts while waiting so the application can finish asynchronous work and repaint; this wait also applies when ScriptedInput.RealTime is false.
Parameters
- capture ConsoleMonster.Interactive.ScreenCapture
- The application's real screen capture.
- text string
- The ordinal, case-sensitive text expected in the current frame.
- timeout System.TimeSpan
- Maximum time from the first read of this step.
Inherited Methods
Properties
public string Name { get; } #A short description for diagnostics, for example windows console (ReadConsoleInputW).
public bool RealTime { get; set; } #Whether pauses (wait:) really sleep. Off by default so tests run instantly; demos turn it on.
public Action<TimeSpan>? SkippedWait { get; set; } #Called for each skipped wait step when ScriptedInput.RealTime is false, before the next input event. A recording host can use ScreenCapture.Hold to retain reading pauses without sleeping.
public bool Paced { get; set; } #When true, a read that does not wait (zero timeout) returns null, so a reader that drains bursts draws a frame after every scripted event (golden tests of each step).
public bool EndsQuietly { get; set; } #When true, reading past the end returns null (a timeout) instead of throwing.