Last active
December 21, 2016 15:22
-
-
Save saggie/073c716267a2cb411d7cb7ce6f49b045 to your computer and use it in GitHub Desktop.
Wait for instant noodles get done
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param([int]$Minutes = 3) | |
$appName = "Wait-Noodles" | |
# create a task tray icon | |
Add-Type -AssemblyName System.Windows.Forms | |
$notifyIcon = New-Object System.Windows.Forms.NotifyIcon | |
# get an icon image from powershell.exe | |
$psExeFilePath = Join-Path $Script:PSHOME "powershell.exe" | |
$notifyIcon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($psExeFilePath) | |
# notify the start | |
$notifyIcon.Visible = $true | |
$notifyIcon.ShowBalloonTip(5000, "Start", "$appName has started.", "Info") | |
# wait | |
$startTicks = (Get-Date).Ticks | |
$targetSec = $Minutes * 60 | |
do | |
{ | |
$elapsedSec = ((Get-Date).Ticks - $startTicks) / 10000000 | |
$remainingSec = $targetSec - [int]$elapsedSec | |
$notifyIcon.Text = "$appName - Remaining $remainingSec seconds" | |
Start-Sleep -Seconds 1 | |
} | |
while ($elapsedSec -lt $targetSec) | |
# notify the end | |
$notifyIcon.ShowBalloonTip(5000, "End", "$appName has ended.", "Info") | |
$notifyIcon.Visible = $false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: