New filters on the Home Feed, take a look!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

8
Interrupt loop only if someone presses a key
Post Body

Hi /r/powershell,

is there a way to interrupt a loop only if someone presses a key? Or in other words, is it possible to wait for input only a certain amount of time?

Pseudo code:

while ($true){

    Process-Things

    $key = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") -StopReadKeyAfterOneSecond

    if ($key) {
        Process-OtherThings
    }

}

Author
Account Strength
90%
Account Age
15 years
Verified Email
Yes
Verified Flair
No
Total Karma
4,540
Link Karma
3,347
Comment Karma
1,193
Profile updated: 4 days ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
6 years ago