Creating a real-time console display

Sorry I wasn’t more specific in this subject but I’m not sure how to describe what I’m thinking. I want to start a project that requires a stock ticker-like output in the Powershell console. I’m not sure where to even start with this. I want to provide a layout (text, console-based output only) that will have multiple “fields”. Each of these “fields” will simply be the output of a Write-Host.

I want to run another script in parallel with this console layout that will send output from that script to this layout only by updating a specified field.

Here’s my attempt at explaining this better in a screenshot.

I essentially want a “ReplaceAndWrite-Host” cmdlet. Something that will replace text in a particular spot in the console and update it without any interaction.

How would I even start this?

Depending on what else is going on in that window, you can use [Console]::SetCursorPosition() followed by [Console]::Write() or ::WriteLine(). You can retrieve the current cursor position with [Console]::CursorLeft and [Console]::CursorTop , and put it back where you found it with another call to [Console]::SetCursorPosition() after drawing your stuff.

Alternatively, you can just clear the console and re-draw your entire UI on every refresh, if you prefer. Either way, it makes me want to go play Zork again. :slight_smile:

(The console APIs will only work properly in powershell.exe, btw. Don’t expect to be able to test that in the ISE.)

Nice! Thanks as always, Dave. The [Console] object is exactly what I needed. I wasn’t aware of that. Thanks!