Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
farag2 committed Jul 10, 2023
1 parent 661aa4a commit fdbe134
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 86 deletions.
50 changes: 36 additions & 14 deletions src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,20 @@ public static string GetString(uint strId)
.SYNOPSIS
The "Show menu" function with the up/down arrow keys and enter key to make a selection
.PARAMETER Title
Add title
.PARAMETER Menu
Array of items to choose from
.PARAMETER Default
Default selected item in array
.PARAMETER AddSkip
Add localized extracted "Skip" string from shell32.dll
.EXAMPLE
Show-Menu -Menu $ListOfItems -Default $DefaultChoice
Show-Menu -Menu $Items -Default 1
.LINK
https://qna.habr.com/answer?answer_id=1522379
Expand All @@ -865,14 +877,24 @@ public static string GetString(uint strId)

[Parameter(Mandatory = $true)]
[int]
$Default
$Default,

[Parameter(Mandatory = $false)]
[switch]
$AddSkip
)

Write-Information -MessageData $Title -InformationAction Continue

# Extract the localized "Waiting for confirmation" string from shell32.dll
$Menu += [WinAPI.GetStr]::GetString(33252)

if ($AddSkip)
{
# Extract the localized "Skip" string from shell32.dll
$Menu += [WinAPI.GetStr]::GetString(16956)
}

# https://github.com/microsoft/terminal/issues/14992
[System.Console]::BufferHeight += $Menu.Count
$minY = [Console]::CursorTop
Expand Down Expand Up @@ -7274,11 +7296,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Desktop -FolderPath "$($Choice)\Desktop" -RemoveDesktopINI
}
Expand All @@ -7302,11 +7324,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Documents -FolderPath "$($Choice)\Documents" -RemoveDesktopINI
}
Expand All @@ -7330,11 +7352,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Downloads -FolderPath "$($Choice)\Downloads" -RemoveDesktopINI
}
Expand All @@ -7358,11 +7380,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Music -FolderPath "$($Choice)\Music" -RemoveDesktopINI
}
Expand All @@ -7386,11 +7408,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Pictures -FolderPath "$($Choice)\Pictures" -RemoveDesktopINI
}
Expand All @@ -7414,11 +7436,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Videos -FolderPath "$($Choice)\Videos" -RemoveDesktopINI
}
Expand Down
50 changes: 36 additions & 14 deletions src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,20 @@ public static string GetString(uint strId)
.SYNOPSIS
The "Show menu" function with the up/down arrow keys and enter key to make a selection
.PARAMETER Title
Add title
.PARAMETER Menu
Array of items to choose from
.PARAMETER Default
Default selected item in array
.PARAMETER AddSkip
Add localized extracted "Skip" string from shell32.dll
.EXAMPLE
Show-Menu -Menu $ListOfItems -Default $DefaultChoice
Show-Menu -Menu $Items -Default 1
.LINK
https://qna.habr.com/answer?answer_id=1522379
Expand All @@ -715,14 +727,24 @@ public static string GetString(uint strId)

[Parameter(Mandatory = $true)]
[int]
$Default
$Default,

[Parameter(Mandatory = $false)]
[switch]
$AddSkip
)

Write-Information -MessageData $Title -InformationAction Continue

# Extract the localized "Waiting for confirmation" string from shell32.dll
$Menu += [WinAPI.GetStr]::GetString(33252)

if ($AddSkip)
{
# Extract the localized "Skip" string from shell32.dll
$Menu += [WinAPI.GetStr]::GetString(16956)
}

# https://github.com/microsoft/terminal/issues/14992
[System.Console]::BufferHeight += $Menu.Count
$minY = [Console]::CursorTop
Expand Down Expand Up @@ -5909,11 +5931,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Desktop -FolderPath "$($Choice)\Desktop" -RemoveDesktopINI
}
Expand All @@ -5937,11 +5959,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Documents -FolderPath "$($Choice)\Documents" -RemoveDesktopINI
}
Expand All @@ -5965,11 +5987,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Downloads -FolderPath "$($Choice)\Downloads" -RemoveDesktopINI
}
Expand All @@ -5993,11 +6015,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Music -FolderPath "$($Choice)\Music" -RemoveDesktopINI
}
Expand All @@ -6021,11 +6043,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Pictures -FolderPath "$($Choice)\Pictures" -RemoveDesktopINI
}
Expand All @@ -6049,11 +6071,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Videos -FolderPath "$($Choice)\Videos" -RemoveDesktopINI
}
Expand Down
50 changes: 36 additions & 14 deletions src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,20 @@ public static string GetString(uint strId)
.SYNOPSIS
The "Show menu" function with the up/down arrow keys and enter key to make a selection
.PARAMETER Title
Add title
.PARAMETER Menu
Array of items to choose from
.PARAMETER Default
Default selected item in array
.PARAMETER AddSkip
Add localized extracted "Skip" string from shell32.dll
.EXAMPLE
Show-Menu -Menu $ListOfItems -Default $DefaultChoice
Show-Menu -Menu $Items -Default 1
.LINK
https://qna.habr.com/answer?answer_id=1522379
Expand All @@ -718,14 +730,24 @@ public static string GetString(uint strId)

[Parameter(Mandatory = $true)]
[int]
$Default
$Default,

[Parameter(Mandatory = $false)]
[switch]
$AddSkip
)

Write-Information -MessageData $Title -InformationAction Continue

# Extract the localized "Waiting for confirmation" string from shell32.dll
$Menu += [WinAPI.GetStr]::GetString(33252)

if ($AddSkip)
{
# Extract the localized "Skip" string from shell32.dll
$Menu += [WinAPI.GetStr]::GetString(16956)
}

# https://github.com/microsoft/terminal/issues/14992
[System.Console]::BufferHeight += $Menu.Count
$minY = [Console]::CursorTop
Expand Down Expand Up @@ -6299,11 +6321,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Desktop -FolderPath "$($Choice)\Desktop" -RemoveDesktopINI
}
Expand All @@ -6327,11 +6349,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Documents -FolderPath "$($Choice)\Documents" -RemoveDesktopINI
}
Expand All @@ -6355,11 +6377,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Downloads -FolderPath "$($Choice)\Downloads" -RemoveDesktopINI
}
Expand All @@ -6383,11 +6405,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Music -FolderPath "$($Choice)\Music" -RemoveDesktopINI
}
Expand All @@ -6411,11 +6433,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Pictures -FolderPath "$($Choice)\Pictures" -RemoveDesktopINI
}
Expand All @@ -6439,11 +6461,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int

do
{
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1]
$Choice = Show-Menu -Title "" -Menu $DriveLetters -Default $DriveLetters.Count[-1] -AddSkip

switch ($Choice)
{
{$DriveLetters -notcontains $Skip}
{$DriveLetters -contains $Choice}
{
Set-UserShellFolder -UserFolder Videos -FolderPath "$($Choice)\Videos" -RemoveDesktopINI
}
Expand Down
Loading

0 comments on commit fdbe134

Please sign in to comment.