Skip to content

Commit

Permalink
fix(installer): hide irrelevant window
Browse files Browse the repository at this point in the history
  • Loading branch information
amorphobia committed Dec 22, 2024
1 parent 9bf0648 commit 567eb24
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions scripts/installer.bat
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,10 @@ function Add-Dependancies {
MemberDefinition = @"
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
internal static extern int ExtractIconEx(string sFile, int iIndex, out IntPtr piLargeVersion, out IntPtr piSmallVersion, int amountIcons);
[DllImport("kernel32.dll")]
internal static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
internal static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
internal static extern bool SetForegroundWindow(IntPtr handle);
[DllImport("user32.dll")]
internal static extern bool ShowWindow(IntPtr handle, int state);

public static void HideConsole() {
IntPtr handle = GetConsoleWindow();
SetForegroundWindow(handle);
handle = GetForegroundWindow();
public static void HideConsole(IntPtr handle) {
ShowWindow(handle, 0);
}

Expand Down Expand Up @@ -252,8 +243,7 @@ function Start-MainGui {
# Not work for Windows Terminal, which is default console from Windows 11
# [WinAPI.Utils]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0) | Out-Null

# Hide the terminal window: https://stackoverflow.com/a/78577080/6676742
[WinAPI.Utils]::HideConsole()
[WinAPI.Utils]::HideConsole(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle)

$XAML = Get-GuiXAML
$XMLForm = [Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $XAML))
Expand Down

0 comments on commit 567eb24

Please sign in to comment.