Closed htcfreek closed 1 year ago
A possible implementation you can find at https://gist.github.com/F1reF0x/abbd05668719b5670f07736b1eb5ac5f
@F1reF0x Can you post the auto hide code here? Can't access the link.
# .Net methods for hiding/showing the console in the background
# Usage: show-console -show / show-console -hide
function Show-Console
{
param ([Switch]$Show,[Switch]$Hide)
if (-not ("Console.Window" -as [type])) {
Add-Type -Name Window -Namespace Console -MemberDefinition '
[DllImport("Kernel32.dll")]
public static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
'
}
if ($Show)
{
$consolePtr = [Console.Window]::GetConsoleWindow()
# Hide = 0,
# ShowNormal = 1,
# ShowMinimized = 2,
# ShowMaximized = 3,
# Maximize = 3,
# ShowNormalNoActivate = 4,
# Show = 5,
# Minimize = 6,
# ShowMinNoActivate = 7,
# ShowNoActivate = 8,
# Restore = 9,
# ShowDefault = 10,
# ForceMinimized = 11
$null = [Console.Window]::ShowWindow($consolePtr, 5)
}
if ($Hide)
{
$consolePtr = [Console.Window]::GetConsoleWindow()
#0 hide
$null = [Console.Window]::ShowWindow($consolePtr, 0)
}
}
Before showing the Dialog just
show-console -hide
When you start the powershell script: before the Dialog is shown, the console window will be hidden. After ShowDialog() you can:
show-console -show
Fixed and fix released with version 1.2
.
Same as the title.