Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ShowMenu
- {
- param
- (
- [Parameter(Mandatory = $true)]
- [string]
- $Title,
- [Parameter(Mandatory = $true)]
- [array]
- $Options,
- [Parameter(Mandatory = $true)]
- [int]
- $Default
- )
- Write-Host $Title
- $minY = [Console]::CursorTop
- $y = [Math]::Max([Math]::Min($Default, $Options.Count), 0)
- do
- {
- [Console]::CursorTop = $minY
- [Console]::CursorLeft = 0
- $i = 0
- foreach ($item in $Options)
- {
- $colors = @{
- BackgroundColor = if ($i -ne $y)
- {
- [Console]::BackgroundColor
- }
- else
- {
- "Cyan"
- }
- ForegroundColor = if ($i -ne $y)
- {
- [Console]::ForegroundColor
- }
- else
- {
- "Blue"
- }
- }
- Write-Host (' {0}. {1} ' -f ($i+1), $item) @colors
- $i++
- }
- switch ([Console]::ReadKey().Key)
- {
- "UpArrow"
- {
- if ($y -gt 0)
- {
- $y--
- }
- }
- "DownArrow"
- {
- if ($y -lt ($Options.Count - 1))
- {
- $y++
- }
- }
- "Enter"
- {
- return $Options[$y]
- }
- }
- }
- while ([Console]::ReadKey().Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter))
- }
- if ($RU)
- {
- $Title = "Выберите букву диска"
- }
- else
- {
- $Title = "Desktop"
- }
- #$Options = 'test1', 'text2', 'menu3', 'result4'
- $Options = [string[]](Get-Disk | Where-Object -FilterScript {$_.BusType -ne "USB"} | Get-Partition | Get-Volume | Where-Object -FilterScript {$null -ne $_.DriveLetter}).DriveLetter | Sort-Object
- ShowMenu -Title $Title -Options $Options -Default 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement