Skip to content
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

Stopping countdown from scrolling down content of PS window #15962

Closed
GitHubinatrix opened this issue Sep 13, 2023 · 3 comments
Closed

Stopping countdown from scrolling down content of PS window #15962

GitHubinatrix opened this issue Sep 13, 2023 · 3 comments
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Issue-Question For questions or discussion Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-Answered Related to questions that have been answered

Comments

@GitHubinatrix
Copy link

GitHubinatrix commented Sep 13, 2023

I have read these two to discussions

#6062

#15059

but as I am not a programmer, just a small time script tweaker, can anyone summarize / explain to me these two discussion in more layman terms?

I have this OK working test code

Write-Host "Line of text at the very top"
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host "Line of text in the middle"
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host "Last line of text"

Write-Host "Executing in:"
Write-Host



# Countdown:

$topRow = [System.Console]::CursorTop

10..0 | ForEach-Object {
    [System.Console]::SetCursorPosition(0, $topRow)

    if ($_ -eq 10) {
        Write-Host $_ -NoNewline
    } else {
        Write-Host " $_" -NoNewline
    }

    Start-Sleep -Seconds 1
    Write-Host " `b" -NoNewline
}



# Here will be the main script

Write-Host
Write-Host "Script has been executed"



# Wait for specific user input (ESC, ENTER, or SPACE) before closing the window:

Write-Host "To close this window press either:
Enter
Space
Esc"
Write-Host

do {
    $key = $Host.UI.RawUI.ReadKey('NoEcho, IncludeKeyDown').Character
} while ($key -notin @(' ', [char]13, [char]27))

which stops the PowerShell window at countdown - and after it ends it then proceeds with execution of the rest of the script

But the problem with it that I have is that every appearing digit makes the PS window scroll down its content to the very bottom - thus I can only see what is above this active counter for less than second afterl scrolling up. I can constantly scroll manually but it always goes back to the bottom to show a new digit. I could of course replace that with a silent countdown like this


$CountdownSeconds = 10
Write-Host "Executing in:"
Write-Host $CountdownSeconds
Write-Host "seconds"
Start-Sleep -Seconds $CountdownSeconds

but at a cost of not being informed then about how much time has left

So is there a way to eat a cake and have it - i.e. to see a digits of countdown at the bottom of window but also at any time to be able to scroll up not have the view thrown back down every second?

@GitHubinatrix GitHubinatrix added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Sep 13, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Sep 13, 2023
@zadjii-msft
Copy link
Member

Ah, you're using the vintage console window, conhost.exe, aren't you/?

Here's a great solution! Go try the Windows Terminal instead. In the Terminal, we've updated this to only snap to the bottom on output, if you're already at the bottom. If you scroll up, then we won't snap to the bottom on output.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Sep 20, 2023
@GitHubinatrix
Copy link
Author

Thank you for informing me

But because there are many prerequisites for running Windows Terminal on Windows 10 and my time and skills are limited [and I just know, based on my past experiences, that I will stumble on some issues with upgrading my system] thus I think I will just wait out for the time when I will build a new machine with Windows 11 installed on it - as Wikipedia says that is by default replaced with Windows Terminal since Windows 11 22H2

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Sep 21, 2023
@zadjii-msft
Copy link
Member

Ah - those are the pre-reqs for building the Terminal locally. If you just want to install it, you can grab it from the Store, or straight off our Releases page.

@zadjii-msft zadjii-msft closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2023
@zadjii-msft zadjii-msft added Issue-Question For questions or discussion Resolution-Answered Related to questions that have been answered labels Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Issue-Question For questions or discussion Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-Answered Related to questions that have been answered
Projects
None yet
Development

No branches or pull requests

2 participants