diff --git a/functions/private/Invoke-WinUtilStickyKeys b/functions/private/Invoke-WinUtilStickyKeys.ps1 similarity index 100% rename from functions/private/Invoke-WinUtilStickyKeys rename to functions/private/Invoke-WinUtilStickyKeys.ps1 diff --git a/functions/public/Invoke-MinimizeButton.ps1 b/functions/public/Invoke-MinimizeButton.ps1 new file mode 100644 index 00000000..9002705a --- /dev/null +++ b/functions/public/Invoke-MinimizeButton.ps1 @@ -0,0 +1,7 @@ +function Invoke-WPFMinimizeButton { + <# + .SYNOPSIS + Minimize the application window + #> + $sync["Form"].WindowState = [System.Windows.WindowState]::Minimized +} \ No newline at end of file diff --git a/functions/public/Invoke-WPFButton.ps1 b/functions/public/Invoke-WPFButton.ps1 index 3bd0428f..47e1ac7d 100644 --- a/functions/public/Invoke-WPFButton.ps1 +++ b/functions/public/Invoke-WPFButton.ps1 @@ -52,6 +52,8 @@ function Invoke-WPFButton { "WPFGetInstalledTweaks" {Invoke-WPFGetInstalled -CheckBox "tweaks"} "WPFGetIso" {Invoke-WPFGetIso} "WPFMicrowin" {Invoke-WPFMicrowin} + "WPFMinimizeButton" {Invoke-WPFMinimizeButton} + "WPFMaximizeButton" {Invoke-WPFMaximizeButton} "WPFCloseButton" {Invoke-WPFCloseButton} "MicrowinScratchDirBT" {Invoke-ScratchDialog} } diff --git a/functions/public/Invoke-WPFMaximizeButton.ps1 b/functions/public/Invoke-WPFMaximizeButton.ps1 new file mode 100644 index 00000000..25b17906 --- /dev/null +++ b/functions/public/Invoke-WPFMaximizeButton.ps1 @@ -0,0 +1,11 @@ +function Invoke-WPFMaximizeButton { + <# + .SYNOPSIS + Alternates between Maximized and Minimized window + #> + if ($sync["Form"].WindowState -eq [System.Windows.WindowState]::Maximized) { + $sync["Form"].WindowState = [System.Windows.WindowState]::Normal + } else { + $sync["Form"].WindowState = [System.Windows.WindowState]::Maximized + } +} \ No newline at end of file diff --git a/winutil.ps1 b/winutil.ps1 index 3e750be9..0f48a912 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -10,7 +10,7 @@ Author : Chris Titus @christitustech Runspace Author: @DeveloperDurp GitHub : https://github.com/ChrisTitusTech - Version : 24.02.07 + Version : 24.02.09 #> param ( [switch]$Debug, @@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms # Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "24.02.07" +$sync.version = "24.02.09" $sync.configs = @{} $sync.ProcessRunning = $false @@ -2336,6 +2336,13 @@ Function Update-WinUtilProgramWinget { $global:WinGetInstall = Start-Process -Verb runas powershell -ArgumentList "-command invoke-command -scriptblock {$wingetinstall} -argumentlist '$($ProgramsToInstall -join ",")'" -PassThru } +function Invoke-WPFMinimizeButton { + <# + .SYNOPSIS + Minimize the application window + #> + $sync["Form"].WindowState = [System.Windows.WindowState]::Minimized +} function Invoke-ScratchDialog { @@ -2419,6 +2426,8 @@ function Invoke-WPFButton { "WPFGetInstalledTweaks" {Invoke-WPFGetInstalled -CheckBox "tweaks"} "WPFGetIso" {Invoke-WPFGetIso} "WPFMicrowin" {Invoke-WPFMicrowin} + "WPFMinimizeButton" {Invoke-WPFMinimizeButton} + "WPFMaximizeButton" {Invoke-WPFMaximizeButton} "WPFCloseButton" {Invoke-WPFCloseButton} "MicrowinScratchDirBT" {Invoke-ScratchDialog} } @@ -3243,6 +3252,17 @@ function Invoke-WPFInstallUpgrade { Write-Host "-- You can close this window if desired ---" Write-Host "===========================================" } +function Invoke-WPFMaximizeButton { + <# + .SYNOPSIS + Alternates between Maximized and Minimized window + #> + if ($sync["Form"].WindowState -eq [System.Windows.WindowState]::Maximized) { + $sync["Form"].WindowState = [System.Windows.WindowState]::Normal + } else { + $sync["Form"].WindowState = [System.Windows.WindowState]::Maximized + } +} function Invoke-WPFMicrowin { <# .DESCRIPTION @@ -3829,6 +3849,48 @@ function Invoke-WPFRunspace { [System.GC]::Collect() } } +function Invoke-WPFSetWindowSize { + <# + .SYNOPSIS + Sets the window size according to the display resolution + #> + + param ($xamlContent) + $xamlContent = @" + +"@ + + [xml]$xaml = $xamlContent + $reader = New-Object System.Xml.XmlNodeReader $xaml + try { + $window = [Windows.Markup.XamlReader]::Load($reader) + } + catch { + Write-Error "Failed to load XAML: $_" + return + } + + Add-Type -AssemblyName System.Windows.Forms + $primaryScreen = [System.Windows.Forms.Screen]::PrimaryScreen + $bounds = $primaryScreen.Bounds + + $newHeight = $window.FindName("MainWindow") + + if ($bounds.Height -lt 1080) { + $newHeight.Height = 720 + } + Write-Host "$newHeight" +} function Invoke-WPFShortcut { <# @@ -4463,6 +4525,7 @@ $inputXML = ' @@ -5074,6 +5137,8 @@ $inputXML = ' + + @@ -619,6 +620,8 @@ + + +