mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-15 15:15:51 -06:00
a8af90a112
* Several Additions to 'applications.json' File (#1865) * Add 'ditto' App to 'applications.json' File * Add 'rdcman' App to 'applications.json' File * Add 'mp3tag' App to 'applications.json' File * Add 'fan control' App to 'applications.json' File * Compile Winutil * Add 'betterbird' App to 'applications.json' File (#1876) * Compile Winutil * Added fnm to the install menu (#1879) * Compile Winutil * Update applications.json (#1883) * Compile Winutil * Simple improvement: make WinUtil's Shortcut Function Do Less (Lazier) (#1903) * Add Extra Comments to 'Invoke-WPFShortcut' to make the Logic a Bit Clearer * Make The 'Invoke-WPFShortcut' Function Lazier for Added Efficiency and to not Display False Info whenever the User Cancels the 'Save As' Operation * Compile Winutil * Update applications.jsonremove Whatsapp because it is not being maintained and is named "outdated" when installed * Update applications.json remove Whatsapp because it is not being maintained and is named "outdated" when installed * Compile Winutil * Add option to remove Microsoft Copilot AI * Add option to remove MS Copilot * Update tweaks.json * fix bugs - remove appx caused a lockup - also it looks like copilot will be the dependency for some built-in windows searches Due to this I am changing it from a removal to a disable. * Compile Winutil * remove authy authy reached EOLhttps://help.twilio.com/articles/22771146070299-User-guide-End-of-Life-EOL-for-Twilio-Authy-Desktop-app * remove authy authy reached EOL https://help.twilio.com/articles/22771146070299-User-guide-End-of-Life-EOL-for-Twilio-Authy-Desktop-app * Compile Winutil * Update applications.jsonWindhawkThe customization marketplace for Windows programshttps://www.youtube.com/watch?v=ijG0nXnO2gQ * Update applications.json Windhawk The customization marketplace for Windows programs https://www.youtube.com/watch?v=ijG0nXnO2gQ * add MSEdgeRedirect to applications.jsonperhaps a good "tweak" that could be added to Tweaks section down the road. project is foss... could be a good resource for someone with enough skills.in the meantime, does what it says it will, and does it well. * add MSEdgeRedirect to applications.json perhaps a good "tweak" that could be added to Tweaks section down the road. project is foss... could be a good resource for someone with enough skills. in the meantime, does what it says it will, and does it well. * Fix Winget Detection by doing Proper Error Handling using a Try-Catch * Fix Winget Detection by doing Proper Error Handling using a Try-Catch * Remove unnecessary Variable Initialization of 'wingetFullVersion' Co-authored-by: Martin Wiethan <47688561+Marterich@users.noreply.github.com> * Add Comments to be make The Logic a Lot More Clear to Follow and Understand * Add Another Catch Statement with some 'Write-Warning' for Extra Information * Remove StartAllBack + Adobe Debloater Tweak + Add Netbird * remove StartAllBack * Added Adobe Service Debloater Sets Adobe Services to manual for people that sadly need to work with their apps. * Add Netbird https://netbird.io * Compile Winutil * Update applications.json * Compile Winutil * Added ability to import drivers * Added ability to import drivers Added the ability to import drivers from the active installation to the MicroWin image. * Merge branch 'test-2024-04-20-2' into CW-MicroWin-240420 * Update inputXML.xaml Removed warning because of a fluke * Update Invoke-WPFMicrowin.ps1 Use the driver injection directory if it is specified and if the directory exists * Merge branch 'test-2024-04-20-2' into CW-MicroWin-240420 * Merge branch 'test-2024-04-20-2' into CW-MicroWin-240420 * Compile Winutil * Test 2024 04 20 2 | 7 additions to applications.json * 7 additions to applications.json Adds: NetLimiter - https://www.netlimiter.com OneCommander - https://www.onecommander.com Borderless Gaming - https://github.com/Codeusa/Borderless-Gaming Equalizer APO - https://sourceforge.net/projects/equalizerapo FreeFileSync - https://freefilesync.org Elgato Stream Deck - https://www.elgato.com/uk/en/s/downloads Stardock Curtains - https://www.stardock.com/products/curtains * Added Compact GUI support Link: https://github.com/IridiumIO/CompactGUI Since I wasn't sure what category to put it in, I chose Utilities. * Added ExifCleaner support Link: https://github.com/szTheory/exifcleaner * Removed trial ware additions Removed: Net Limiter One Commander Elgato: Stream Deck Stardock Curtains * Compile Winutil * add GlazeWM to applications.js (#1891) Co-authored-by: Chris Titus <contact@christitus.com> * Compile Winutil * Remove old Win7 game tweak * Compile Winutil * Test 1715290913 fix ugly ifs (#1957) * fix nested ifs * Compile Winutil * fix syntax * Compile Winutil * Add Spotify and Choco Fallback * Compile Winutil --------- Co-authored-by: ty802 <ty802@users.noreply.github.com> Co-authored-by: Chris Titus <contact@christitus.com> Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com> * Compile Winutil * Fix incorrect url for jellyfin-media-player (#1912) * Compile Winutil * Update name and description for Element (#1930) - Fixed the name and description for Element to reflect the name of the client, rather than the underlying technology-Matrix. * Compile Winutil * Optimize winget download speed (#1931) * Optimize Winget Download Speed * Add Downloading Message * Compile Winutil * Include OOSU Config in winutil.ps1 (#1932) * Compile Winutil * Only install choco if needed (#1943) * Compile Winutil * Install Choco if needed * Compile Winutil * Added ForceAutoHDR application to applications.json (#1951) * Added ForceAutoHDR application to applications.json Entry added on line 2642 * Update config/applications.json Yep my bad I though games related tools should be under "Games" Co-authored-by: Mr.k <mineshtine28546271@gmail.com> --------- Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * Compile Winutil * add Godot Engine to applications.json (#1933) Added Godot Engine (https://godotengine.org/). Godot Engine is a free, open-source 2D and 3D game engine with a focus on usability and flexibility. * Compile Winutil * Add GitKraken Client (#1927) Adds development utility client for git repository management * Compile Winutil * Simplified Admin Check and Added Code Comments (#1938) - Simplified the admin check by filtering the "WindowsIdentity" class for owner value and comparing against admin value - Removed the need for an if admin check by moving its commands under the if not admin check. - Added code comments * Compile Winutil * Main window handle (#1941) Condition is comparing $proc.Id with [System.IntPtr]::Zero. The Id property is an integer, representing the process ID, and it's not directly related to window handles. Instead, you should compare the MainWindowHandle property against [System.IntPtr]::Zero * Compile Winutil * Add SMPlayer to `applications.json` (#1948) * Add SMPlayer to `applications.json` * Fix formatting --------- Co-authored-by: Chris Titus <contact@christitus.com> * Compile Winutil * Adobe Network Blocking / Adobe Debloater / Tweak Fixes & more (#1954) * Added Applications AFFiNE: Open source Notion alternative with selfhostable option for syncing. Wazuh Agent: Adgent for open-source security monitoring platform * Change layout of toggles Change the layout of the toggles to first show toggles and then the content (text). - testet, works * added snap related toggles - disable snapping entirely (requires relogin of windows user) - disable suggestion to snap other windows next to the snapped window -tested * Layouted Checkboxes, redesigned Toggles & renamed RDCMan - Removed text inside toggle as it can be confusing because it sais "enable" while enabled and "disable" if disabled. The coloring should be enough to know in what state that setting is. - without the text i could make it a little bit smaller while still letting it look good. - Renamed "Remote Desktop Connection Manager (RDCMan)" to "RDCMan" because that name is shorter and also mostly used by the linked site. - layouted checkboxes so they are not more left than the title and look tidy. - tested * Disable Acrobat auto-updates - added script & undoscript to disable automatic downloads & installation of acrobat reader. The user gets a notified if there is an update available. I put some info to that inside the code * edited AFFiNE description * Tweak Adobe Debloater -disable Adobe Desktop Service by getting ownership and renaming it. - added AGMService service - disable AGMService and AGSService entirely * Block Adobe Network, Debloat Adobe & Compile - fixes order of tweaks to always run "WPFTweaksRestorePoint" first. Before it was only the case because if was one of the first letter0s of the alphabet - Fixed some stuff at Debloat Adobe & added Adobe Reader update stopper & "deactivated" Adobe Desktop Service. - Added Blocking of Adobe Servers (as of your suggestion) to it's own Tweak. - ran compile for testing & showing * undo compilation * added Note to AcrobatUpdates Management in Tweak "Debloat Adobe" * Fix Right Click Method to use accurate names * fixed my mistake in README --------- Co-authored-by: Chris Titus <contact@christitus.com> * Compile Winutil * Install flow rework (#1961) * Install flow rework Sperated Winget and Chocolatey setps when installing software add skip them when not needed * fix uninstall --------- Co-authored-by: Chris Titus <contact@christitus.com> * Compile Winutil * Made disabling Fullscreen optimizations its own tweak (#1934) * Removed "GameDVR_DXGIHonorFSEWindowsCompatible" modification from "Disable GameDVR" tweak * Created advanced tweak "Disable fullscreen optimizations" Disables fullscreen optimizations in all applications. (Which can cause problems with Color Management in Exclusive Fullscreen) * Compile Winutil * fix glaze * Compile Winutil * Fix Typo in the App Entry 'GlazeWM' in 'applications.json' File (#1958) * Reorder Tweaks * Fix ordering of Advanced Tweaks * Compile Winutil * Preset Update * Organize Tweaks * Compile Winutil * Add the pixi package manager * Add the pixi package manager * Compile Winutil * Add Arc Browser to the application list. * Add Arc Browser to the application list. * Compile Winutil * Update applications.json - Added NDI toolsNDI, or Network Device Interface, is developed by Newtek. It enables the encoding, transmission, and reception of high-quality, low latency, video and audio over IP.https://ndi.video/Apologies if I'm not doing this right. I have zero experience using Github. * Update applications.json - Added NDI tools NDI, or Network Device Interface, is developed by Newtek. It enables the encoding, transmission, and reception of high-quality, low latency, video and audio over IP. https://ndi.video/ Apologies if I'm not doing this right. I have zero experience using Github. * Compile Winutil * docs: minor spellchecking * docs: minor spellchecking * Fix scratch textbox bug * Fix scratch textbox bug * Fixing Microwin, no more errors and it creats image now without issues * Compile Winutil * Tweaks page overhaul: * Toggle page overhaul: * Modern toggles + Tweak: Disable Copilot + Tweak: Set hibernation to default (fix issue https://github.com/ChrisTitusTech/winutil/issues/1399) * Merge branch 'test-2024-04-20-2' into TweaksToggles * Compile Winutil * Able to set the Default Terminal to Powershell 7 in Windows Terminal * Run winget in open powershell window if possible and handle update * add return code reference * Seperated Logic for PS7 Profile change * Add tweak * Revert changes to last commit in Christitus Repo * Merge pull request #1 from Marterich/PS7profile Split Logic in different Script, Re-Add files with to reflect Chris's Repo * Compile Winutil * Update tweaks.json * Compile Winutil * Update tweaks.json * Compile Winutil * disables to disable * Compile Winutil * Update applications.json - Files, ditto, spotube, sagethumbs added & file converter choco variable fixed (#1996) Added Files, ditto, spotube and sagethumbs. Fixed File Converted by Adrien Allard with proper Choco variable. "files">"file-conveter" "WPFInstallfileconverter": { "category": "Utilities", "choco": "file-converter", "content": "File-Converter", "description": "File Converter is a very simple tool which allows you to convert and compress one or several file(s) using the context menu in windows explorer.", "link": "https://file-converter.io/", "winget": "AdrienAllard.FileConverter" * Compile Winutil * Winget install return code handling & Window management (#1992) * Run winget in open powershell window if possible and handle update * add return code reference * Compile Winutil * Fix typo (#1965) Co-authored-by: Chris Titus <contact@christitus.com> * Change voicemeeter URL to their newer site (#1967) * Compile Winutil * Change voicemeeter URL to newest site * Compile Winutil --------- Co-authored-by: Yuuh15 <Yuuh15@users.noreply.github.com> Co-authored-by: Chris Titus <contact@christitus.com> * Removed broken winget from applications.json (#1968) The winget does not work for vencord. The installer downloads and then fails. (#1515) * Compile Winutil * Optimize Display Behaviour of Category Labels (#1979) * Hide Category title if empty * Changed labels to a hashtable for faster access * Extract WPFNamecreation to function, fix hide all if none match * Compile Winutil * ps1 ext add * Update oosu10 config files and ad missing fileextension (#1980) Co-authored-by: Chris Titus <contact@christitus.com> * Compile Winutil * Fix fallback bug and merge choco uninstall rework (#1962) * Implement Uninstall Command for Chocolatey, and Made a Starting Point on the Automatic Upgrade when a Package is Already Installed, similar to WinGet Install Command * Add Extra Guards/Checks in 'Install-WinUtilProgramChoco' Private Function * Fix fallback bug and merge choco uninstall rework - fixed return from wrong return from winget install Install-WinUtilProgramWinget - syntax/wording cleenup in Install-WinUtilProgramWinget - fix bugs in ty802/winutil#1 after merge --------- Co-authored-by: Mr.k <mineshtine28546271@gmail.com> Co-authored-by: Chris Titus <contact@christitus.com> * Compile Winutil * Update applications.json (#1976) added qgis in right format Co-authored-by: Chris Titus <contact@christitus.com> * Compile Winutil * fix sagethumbs error * Compile Winutil --------- Co-authored-by: Mr.k <mineshtine28546271@gmail.com> Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com> Co-authored-by: Melloni <66322451+MelloniDev@users.noreply.github.com> Co-authored-by: Justawildwolf <62820836+blusewill@users.noreply.github.com> Co-authored-by: MyDrift <personal@mdiana.ch> Co-authored-by: ModernTTY <165050080+ModernTTY@users.noreply.github.com> Co-authored-by: Kasim <kasim@rafique.co.uk> Co-authored-by: trenton4k <trenton4k@gmail.com> Co-authored-by: Evan Galvin <evan.galvin@blissroms.org> Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Co-authored-by: misspent <78914154+misspent@users.noreply.github.com> Co-authored-by: Federico Pulcino <78621373+FedeP14@users.noreply.github.com> Co-authored-by: kian yamamoto <kiany@thatnameisnotavailable.com> Co-authored-by: ty802 <ty802@users.noreply.github.com> Co-authored-by: Callum Carmicheal <callumcarmicheal@gmail.com> Co-authored-by: Rux <jonathan.e.rux@ruxunderscore.com> Co-authored-by: Martin Wiethan <47688561+Marterich@users.noreply.github.com> Co-authored-by: Andrew <121936658+7gxycn08@users.noreply.github.com> Co-authored-by: Jelle <89023848+mrjbongo@users.noreply.github.com> Co-authored-by: Marc Brooks <IDisposable@gmail.com> Co-authored-by: Hayden Plumley <mrhaydendp@gmail.com> Co-authored-by: Berrick Werkman <105836264+BKlaasWerkman@users.noreply.github.com> Co-authored-by: o-iu <168581616+o-iu@users.noreply.github.com> Co-authored-by: Luadih <50816896+Luadih@users.noreply.github.com> Co-authored-by: Morten Enemark Lund <melund@gmail.com> Co-authored-by: Pleș Alexandru <34649178+plesalex100@users.noreply.github.com> Co-authored-by: tvrepairguy <170785918+tvrepairguy@users.noreply.github.com> Co-authored-by: LazyStability <Klysmus@online.de> Co-authored-by: KonTy <9524513+KonTy@users.noreply.github.com> Co-authored-by: drabspirit <39843622+drabspirit@users.noreply.github.com> Co-authored-by: Yuri Gabriel <97139700+Yuuh15@users.noreply.github.com> Co-authored-by: Yuuh15 <Yuuh15@users.noreply.github.com> Co-authored-by: Owen <78411938+Owen-3456@users.noreply.github.com> Co-authored-by: Snoep <128747388+SnoepNFTs@users.noreply.github.com>
484 lines
16 KiB
PowerShell
484 lines
16 KiB
PowerShell
# SPDX-License-Identifier: MIT
|
|
# Set the maximum number of threads for the RunspacePool to the number of threads on the machine
|
|
$maxthreads = [int]$env:NUMBER_OF_PROCESSORS
|
|
|
|
# Create a new session state for parsing variables into our runspace
|
|
$hashVars = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'sync',$sync,$Null
|
|
$InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()
|
|
|
|
# Add the variable to the session state
|
|
$InitialSessionState.Variables.Add($hashVars)
|
|
|
|
# Get every private function and add them to the session state
|
|
$functions = Get-ChildItem function:\ | Where-Object {$_.name -like "*winutil*" -or $_.name -like "*WPF*"}
|
|
foreach ($function in $functions){
|
|
$functionDefinition = Get-Content function:\$($function.name)
|
|
$functionEntry = New-Object System.Management.Automation.Runspaces.SessionStateFunctionEntry -ArgumentList $($function.name), $functionDefinition
|
|
|
|
$initialSessionState.Commands.Add($functionEntry)
|
|
}
|
|
|
|
# Create the runspace pool
|
|
$sync.runspace = [runspacefactory]::CreateRunspacePool(
|
|
1, # Minimum thread count
|
|
$maxthreads, # Maximum thread count
|
|
$InitialSessionState, # Initial session state
|
|
$Host # Machine to create runspaces on
|
|
)
|
|
|
|
# Open the RunspacePool instance
|
|
$sync.runspace.Open()
|
|
|
|
# Create classes for different exceptions
|
|
|
|
class WingetFailedInstall : Exception {
|
|
[string] $additionalData
|
|
|
|
WingetFailedInstall($Message) : base($Message) {}
|
|
}
|
|
|
|
class ChocoFailedInstall : Exception {
|
|
[string] $additionalData
|
|
|
|
ChocoFailedInstall($Message) : base($Message) {}
|
|
}
|
|
|
|
class GenericException : Exception {
|
|
[string] $additionalData
|
|
|
|
GenericException($Message) : base($Message) {}
|
|
}
|
|
|
|
|
|
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
|
|
|
if ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True) {
|
|
if (Invoke-WinUtilGPU -eq $True) {
|
|
$ctttheme = 'Matrix'
|
|
}
|
|
else {
|
|
$ctttheme = 'Dark'
|
|
}
|
|
}
|
|
else {
|
|
$ctttheme = 'Classic'
|
|
}
|
|
$inputXML = Set-WinUtilUITheme -inputXML $inputXML -themeName $ctttheme
|
|
|
|
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
|
|
[xml]$XAML = $inputXML
|
|
|
|
# Read the XAML file
|
|
$reader = (New-Object System.Xml.XmlNodeReader $xaml)
|
|
try { $sync["Form"] = [Windows.Markup.XamlReader]::Load( $reader ) }
|
|
catch [System.Management.Automation.MethodInvocationException] {
|
|
Write-Warning "We ran into a problem with the XAML code. Check the syntax for this control..."
|
|
Write-Host $error[0].Exception.Message -ForegroundColor Red
|
|
If ($error[0].Exception.Message -like "*button*") {
|
|
write-warning "Ensure your <button in the `$inputXML does NOT have a Click=ButtonClick property. PS can't handle this`n`n`n`n"
|
|
}
|
|
}
|
|
catch {
|
|
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
|
|
}
|
|
|
|
#===========================================================================
|
|
# Store Form Objects In PowerShell
|
|
#===========================================================================
|
|
|
|
$xaml.SelectNodes("//*[@Name]") | ForEach-Object {$sync["$("$($psitem.Name)")"] = $sync["Form"].FindName($psitem.Name)}
|
|
|
|
$sync.keys | ForEach-Object {
|
|
if($sync.$psitem){
|
|
if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "CheckBox" `
|
|
-and $sync["$psitem"].Name -like "WPFToggle*"){
|
|
$sync["$psitem"].IsChecked = Get-WinUtilToggleStatus $sync["$psitem"].Name
|
|
|
|
$sync["$psitem"].Add_Click({
|
|
[System.Object]$Sender = $args[0]
|
|
Invoke-WPFToggle $Sender.name
|
|
})
|
|
}
|
|
|
|
if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "ToggleButton"){
|
|
$sync["$psitem"].Add_Click({
|
|
[System.Object]$Sender = $args[0]
|
|
Invoke-WPFButton $Sender.name
|
|
})
|
|
}
|
|
|
|
if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "Button"){
|
|
$sync["$psitem"].Add_Click({
|
|
[System.Object]$Sender = $args[0]
|
|
Invoke-WPFButton $Sender.name
|
|
})
|
|
}
|
|
|
|
if ($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "TextBlock") {
|
|
if ($sync["$psitem"].Name.EndsWith("Link")) {
|
|
$sync["$psitem"].Add_MouseUp({
|
|
[System.Object]$Sender = $args[0]
|
|
Start-Process $Sender.ToolTip -ErrorAction Stop
|
|
Write-Debug "Opening: $($Sender.ToolTip)"
|
|
})
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
#===========================================================================
|
|
# Setup background config
|
|
#===========================================================================
|
|
|
|
# Load computer information in the background
|
|
Invoke-WPFRunspace -ScriptBlock {
|
|
$sync.ConfigLoaded = $False
|
|
$sync.ComputerInfo = Get-ComputerInfo
|
|
$sync.ConfigLoaded = $True
|
|
} | Out-Null
|
|
|
|
#===========================================================================
|
|
# Setup and Show the Form
|
|
#===========================================================================
|
|
|
|
# Print the logo
|
|
Invoke-WPFFormVariables
|
|
|
|
# Install Winget if not already present
|
|
Install-WinUtilWinget
|
|
|
|
# Set the titlebar
|
|
$sync["Form"].title = $sync["Form"].title + " " + $sync.version
|
|
# Set the commands that will run when the form is closed
|
|
$sync["Form"].Add_Closing({
|
|
$sync.runspace.Dispose()
|
|
$sync.runspace.Close()
|
|
[System.GC]::Collect()
|
|
})
|
|
|
|
# Attach the event handler to the Click event
|
|
$sync.CheckboxFilterClear.Add_Click({
|
|
$sync.CheckboxFilter.Text = ""
|
|
$sync.CheckboxFilterClear.Visibility = "Collapsed"
|
|
})
|
|
|
|
# add some shortcuts for people that don't like clicking
|
|
$commonKeyEvents = {
|
|
if ($sync.ProcessRunning -eq $true) {
|
|
return
|
|
}
|
|
|
|
if ($_.Key -eq "Escape")
|
|
{
|
|
$sync.CheckboxFilter.SelectAll()
|
|
$sync.CheckboxFilter.Text = ""
|
|
$sync.CheckboxFilterClear.Visibility = "Collapsed"
|
|
return
|
|
}
|
|
|
|
# don't ask, I know what I'm doing, just go...
|
|
if (($_.Key -eq "Q" -and $_.KeyboardDevice.Modifiers -eq "Ctrl"))
|
|
{
|
|
$this.Close()
|
|
}
|
|
if ($_.KeyboardDevice.Modifiers -eq "Alt") {
|
|
if ($_.SystemKey -eq "I") {
|
|
Invoke-WPFButton "WPFTab1BT"
|
|
}
|
|
if ($_.SystemKey -eq "T") {
|
|
Invoke-WPFButton "WPFTab2BT"
|
|
}
|
|
if ($_.SystemKey -eq "C") {
|
|
Invoke-WPFButton "WPFTab3BT"
|
|
}
|
|
if ($_.SystemKey -eq "U") {
|
|
Invoke-WPFButton "WPFTab4BT"
|
|
}
|
|
if ($_.SystemKey -eq "M") {
|
|
Invoke-WPFButton "WPFTab5BT"
|
|
}
|
|
if ($_.SystemKey -eq "P") {
|
|
Write-Host "Your Windows Product Key: $((Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey)"
|
|
}
|
|
}
|
|
# shortcut for the filter box
|
|
if ($_.Key -eq "F" -and $_.KeyboardDevice.Modifiers -eq "Ctrl") {
|
|
if ($sync.CheckboxFilter.Text -eq "Ctrl-F to filter") {
|
|
$sync.CheckboxFilter.SelectAll()
|
|
$sync.CheckboxFilter.Text = ""
|
|
}
|
|
$sync.CheckboxFilter.Focus()
|
|
}
|
|
}
|
|
|
|
$sync["Form"].Add_PreViewKeyDown($commonKeyEvents)
|
|
|
|
$sync["Form"].Add_MouseLeftButtonDown({
|
|
if ($sync["SettingsPopup"].IsOpen) {
|
|
$sync["SettingsPopup"].IsOpen = $false
|
|
}
|
|
$sync["Form"].DragMove()
|
|
})
|
|
|
|
$sync["Form"].Add_MouseDoubleClick({
|
|
if ($sync["Form"].WindowState -eq [Windows.WindowState]::Normal)
|
|
{
|
|
$sync["Form"].WindowState = [Windows.WindowState]::Maximized;
|
|
}
|
|
else
|
|
{
|
|
$sync["Form"].WindowState = [Windows.WindowState]::Normal;
|
|
}
|
|
})
|
|
|
|
$sync["Form"].Add_Deactivated({
|
|
Write-Debug "WinUtil lost focus"
|
|
if ($sync["SettingsPopup"].IsOpen) {
|
|
$sync["SettingsPopup"].IsOpen = $false
|
|
}
|
|
})
|
|
|
|
$sync["Form"].Add_ContentRendered({
|
|
|
|
try {
|
|
[void][Window]
|
|
} catch {
|
|
Add-Type @"
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
public class Window {
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
|
|
|
|
[DllImport("user32.dll")]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
|
|
|
|
[DllImport("user32.dll")]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
public static extern bool MoveWindow(IntPtr handle, int x, int y, int width, int height, bool redraw);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern int GetSystemMetrics(int nIndex);
|
|
};
|
|
public struct RECT {
|
|
public int Left; // x position of upper-left corner
|
|
public int Top; // y position of upper-left corner
|
|
public int Right; // x position of lower-right corner
|
|
public int Bottom; // y position of lower-right corner
|
|
}
|
|
"@
|
|
}
|
|
|
|
foreach ($proc in (Get-Process | Where-Object { $_.MainWindowTitle -and $_.MainWindowTitle -like "*titus*" })) {
|
|
# Check if the process's MainWindowHandle is valid
|
|
if ($proc.MainWindowHandle -ne [System.IntPtr]::Zero) {
|
|
Write-Debug "MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle) $($proc.MainWindowHandle)"
|
|
$windowHandle = $proc.MainWindowHandle
|
|
} else {
|
|
Write-Warning "Process found, but no MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle)"
|
|
|
|
}
|
|
}
|
|
|
|
# need to experiemnt more
|
|
# setting icon for the windows is still not working
|
|
# $pngUrl = "https://christitus.com/images/logo-full.png"
|
|
# $pngPath = "$env:TEMP\cttlogo.png"
|
|
# $iconPath = "$env:TEMP\cttlogo.ico"
|
|
# # Download the PNG file
|
|
# Invoke-WebRequest -Uri $pngUrl -OutFile $pngPath
|
|
# if (Test-Path -Path $pngPath) {
|
|
# ConvertTo-Icon -bitmapPath $pngPath -iconPath $iconPath
|
|
# }
|
|
# $icon = [System.Drawing.Icon]::ExtractAssociatedIcon($iconPath)
|
|
# Write-Host $icon.Handle
|
|
# [Window]::SendMessage($windowHandle, 0x80, [IntPtr]::Zero, $icon.Handle)
|
|
|
|
$rect = New-Object RECT
|
|
[Window]::GetWindowRect($windowHandle, [ref]$rect)
|
|
$width = $rect.Right - $rect.Left
|
|
$height = $rect.Bottom - $rect.Top
|
|
|
|
Write-Debug "UpperLeft:$($rect.Left),$($rect.Top) LowerBottom:$($rect.Right),$($rect.Bottom). Width:$($width) Height:$($height)"
|
|
|
|
# Load the Windows Forms assembly
|
|
Add-Type -AssemblyName System.Windows.Forms
|
|
$primaryScreen = [System.Windows.Forms.Screen]::PrimaryScreen
|
|
# Check if the primary screen is found
|
|
if ($primaryScreen) {
|
|
# Extract screen width and height for the primary monitor
|
|
$screenWidth = $primaryScreen.Bounds.Width
|
|
$screenHeight = $primaryScreen.Bounds.Height
|
|
|
|
# Print the screen size
|
|
Write-Debug "Primary Monitor Width: $screenWidth pixels"
|
|
Write-Debug "Primary Monitor Height: $screenHeight pixels"
|
|
|
|
# Compare with the primary monitor size
|
|
if ($width -gt $screenWidth -or $height -gt $screenHeight) {
|
|
Write-Debug "The specified width and/or height is greater than the primary monitor size."
|
|
[void][Window]::MoveWindow($windowHandle, 0, 0, $screenWidth, $screenHeight, $True)
|
|
} else {
|
|
Write-Debug "The specified width and height are within the primary monitor size limits."
|
|
}
|
|
} else {
|
|
Write-Debug "Unable to retrieve information about the primary monitor."
|
|
}
|
|
|
|
Invoke-WPFTab "WPFTab1BT"
|
|
$sync["Form"].Focus()
|
|
|
|
# maybe this is not the best place to load and execute config file?
|
|
# maybe community can help?
|
|
if ($PARAM_CONFIG){
|
|
Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG
|
|
if ($PARAM_RUN){
|
|
while ($sync.ProcessRunning) {
|
|
Start-Sleep -Seconds 5
|
|
}
|
|
Start-Sleep -Seconds 5
|
|
|
|
Write-Host "Applying tweaks..."
|
|
Invoke-WPFtweaksbutton
|
|
while ($sync.ProcessRunning) {
|
|
Start-Sleep -Seconds 5
|
|
}
|
|
Start-Sleep -Seconds 5
|
|
|
|
Write-Host "Installing features..."
|
|
Invoke-WPFFeatureInstall
|
|
while ($sync.ProcessRunning) {
|
|
Start-Sleep -Seconds 5
|
|
}
|
|
|
|
Start-Sleep -Seconds 5
|
|
Write-Host "Installing applications..."
|
|
while ($sync.ProcessRunning) {
|
|
Start-Sleep -Seconds 1
|
|
}
|
|
Invoke-WPFInstall
|
|
Start-Sleep -Seconds 5
|
|
|
|
Write-Host "Done."
|
|
}
|
|
}
|
|
|
|
})
|
|
|
|
# Load Checkboxes and Labels outside of the Filter fuction only once on startup for performance reasons
|
|
$filter = Get-WinUtilVariables -Type CheckBox
|
|
$CheckBoxes = $sync.GetEnumerator() | Where-Object { $psitem.Key -in $filter }
|
|
|
|
$filter = Get-WinUtilVariables -Type Label
|
|
$labels = @{}
|
|
$sync.GetEnumerator() | Where-Object {$PSItem.Key -in $filter} | ForEach-Object {$labels[$_.Key] = $_.Value}
|
|
|
|
$allCategories = $checkBoxes.Name | ForEach-Object {$sync.configs.applications.$_} | Select-Object -Unique -ExpandProperty category
|
|
|
|
$sync["CheckboxFilter"].Add_TextChanged({
|
|
|
|
if ($sync.CheckboxFilter.Text -ne "") {
|
|
$sync.CheckboxFilterClear.Visibility = "Visible"
|
|
}
|
|
else {
|
|
$sync.CheckboxFilterClear.Visibility = "Collapsed"
|
|
}
|
|
|
|
$activeApplications = @()
|
|
|
|
foreach ($CheckBox in $CheckBoxes) {
|
|
# Check if the checkbox is null or if it doesn't have content
|
|
if ($CheckBox -eq $null -or $CheckBox.Value -eq $null -or $CheckBox.Value.Content -eq $null) {
|
|
continue
|
|
}
|
|
|
|
$textToSearch = $sync.CheckboxFilter.Text.ToLower()
|
|
$checkBoxName = $CheckBox.Key
|
|
$textBlockName = $checkBoxName + "Link"
|
|
|
|
# Retrieve the corresponding text block based on the generated name
|
|
$textBlock = $sync[$textBlockName]
|
|
|
|
if ($CheckBox.Value.Content.ToLower().Contains($textToSearch)) {
|
|
$CheckBox.Value.Visibility = "Visible"
|
|
$activeApplications += $sync.configs.applications.$checkboxName
|
|
# Set the corresponding text block visibility
|
|
if ($textBlock -ne $null) {
|
|
$textBlock.Visibility = "Visible"
|
|
}
|
|
}
|
|
else {
|
|
$CheckBox.Value.Visibility = "Collapsed"
|
|
# Set the corresponding text block visibility
|
|
if ($textBlock -ne $null) {
|
|
$textBlock.Visibility = "Collapsed"
|
|
}
|
|
}
|
|
}
|
|
$activeCategories = $activeApplications | Select-Object -ExpandProperty category -Unique
|
|
|
|
foreach ($category in $activeCategories){
|
|
$label = $labels[$(Get-WPFObjectName -type "Label" -name $category)]
|
|
$label.Visibility = "Visible"
|
|
}
|
|
if ($activeCategories){
|
|
$inactiveCategories = Compare-Object -ReferenceObject $allCategories -DifferenceObject $activeCategories -PassThru
|
|
}
|
|
else{
|
|
$inactiveCategories = $allCategories
|
|
}
|
|
foreach ($category in $inactiveCategories){
|
|
$label = $labels[$(Get-WPFObjectName -type "Label" -name $category)]
|
|
$label.Visibility = "Collapsed"}
|
|
})
|
|
|
|
# Define event handler for button click
|
|
$sync["SettingsButton"].Add_Click({
|
|
Write-Debug "SettingsButton clicked"
|
|
if ($sync["SettingsPopup"].IsOpen) {
|
|
$sync["SettingsPopup"].IsOpen = $false
|
|
}
|
|
else {
|
|
$sync["SettingsPopup"].IsOpen = $true
|
|
}
|
|
$_.Handled = $false
|
|
})
|
|
|
|
# Define event handlers for menu items
|
|
$sync["ImportMenuItem"].Add_Click({
|
|
# Handle Import menu item click
|
|
Write-Debug "Import clicked"
|
|
$sync["SettingsPopup"].IsOpen = $false
|
|
Invoke-WPFImpex -type "import"
|
|
$_.Handled = $false
|
|
})
|
|
|
|
$sync["ExportMenuItem"].Add_Click({
|
|
# Handle Export menu item click
|
|
Write-Debug "Export clicked"
|
|
$sync["SettingsPopup"].IsOpen = $false
|
|
Invoke-WPFImpex -type "export"
|
|
$_.Handled = $false
|
|
})
|
|
|
|
$sync["AboutMenuItem"].Add_Click({
|
|
# Handle Export menu item click
|
|
Write-Debug "About clicked"
|
|
$sync["SettingsPopup"].IsOpen = $false
|
|
# Example usage
|
|
$authorInfo = @"
|
|
Author : @christitustech
|
|
Runspace : @DeveloperDurp
|
|
GUI : @KonTy
|
|
MicroWin : @KonTy
|
|
GitHub : https://github.com/ChrisTitusTech/winutil
|
|
Version : $($sync.version)
|
|
"@
|
|
Show-CustomDialog -Message $authorInfo -Width 400
|
|
})
|
|
|
|
$sync["Form"].ShowDialog() | out-null
|
|
Stop-Transcript
|