mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-27 16:44:46 -05:00
Test 2024 01 12 (#1401)
* change logseq url and add .net 8 (#1385) * Update applications.json Add Official logseq url Add .net runtime 8.0 * compile with new logseq and .net 8 runtime * add thorium avx2 * Compile Winutil * Remove Cider Music Player (#1400) * Update winutil.ps1 * Update applications.json * Compile Winutil * Import/Export is now global, Settings menu added and many more improvements (#1398) * Anoter one of those huge PRs - Fix version inefficiency the version is already stored in sync, no need to slow down loading by one extra replace. - Created custom dialog and About message - Create a menu with Import/Export values - press on teh Settings cog in the right upper corner and save all the checkboxes - then you can either load them or load and run automatically - Made Import Export load accross the whole app - Optimized the way checkbox controls are looked up, it is 20% faster now - Added a switch to load all the boxes from a config file - example: .winutil.ps1 -Config "C:UsersasdfDesktop\111.json" - Added a switch to run all the action in unattended mode by passing -Run siwthc - example: .winutil.ps1 -Config "C:UsersasdfDesktop\111.json" -Run - This will run all the tweaks and install all the apps * Fixing a couple of bugs and blur fonts, also menu now closes when focus is lost --------- Co-authored-by: KonTy <KonTy@github.com> Co-authored-by: Chris Titus <contact@christitus.com> * Update applications.json * Compile Winutil * Add F8 Recovery Menu and Windows Reg Backup and others (#1389) * Update feature.json append F8 legacy startup and Win Reg Backup and web search suggestion in search app - enable automatic windows registry backup and do schedule for it as well (disabled by default in Win10, Win11) this will help when doing last known Good Configuration thru the F8 startup menu. - enable / disable legacy F8 startup recovery option. - enable / disable web search suggestions in the windows search in task bar. * new tick boxes features. F8 recovery, regbackup, search web suggestions - enable automatic windows registry backup and do schedule for it as well (disabled by default in Win10, Win11) this will help when doing last known Good Configuration thru the F8 startup menu. - enable / disable legacy F8 startup recovery option. - enable / disable web search suggestions in the windows search in task bar. * Compile Winutil * add Parsec to installable applications (#1157) (#1396) Identifiers: - Winget: Parsec.parsec - Chocolatey: parsec * Compile Winutil * add Konty to About page * Compile Winutil * fix description (#1388) (#1402) Co-authored-by: howell2024 <156375832+howell2024@users.noreply.github.com> --------- Co-authored-by: Cristian Negulescu <cristian@clamsen.com> Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com> Co-authored-by: Tommi Pöntinen <98650216+hamburgerghini1@users.noreply.github.com> Co-authored-by: KonTy <9524513+KonTy@users.noreply.github.com> Co-authored-by: KonTy <KonTy@github.com> Co-authored-by: Smartek <70715469+smartekIT@users.noreply.github.com> Co-authored-by: Saikrishnan K <53394202+K-Saikrishnan@users.noreply.github.com> Co-authored-by: howell2024 <156375832+howell2024@users.noreply.github.com>
This commit is contained in:
137
scripts/main.ps1
137
scripts/main.ps1
@ -1,5 +1,4 @@
|
||||
# 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
|
||||
|
||||
@ -129,8 +128,6 @@ catch {
|
||||
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
|
||||
}
|
||||
|
||||
|
||||
|
||||
#===========================================================================
|
||||
# Store Form Objects In PowerShell
|
||||
#===========================================================================
|
||||
@ -168,7 +165,7 @@ $sync.keys | ForEach-Object {
|
||||
$sync["$psitem"].Add_MouseUp({
|
||||
[System.Object]$Sender = $args[0]
|
||||
Start-Process $Sender.ToolTip -ErrorAction Stop
|
||||
Write-Host "Let's go: $($Sender.ToolTip)"
|
||||
Write-Debug "Opening: $($Sender.ToolTip)"
|
||||
})
|
||||
}
|
||||
|
||||
@ -206,7 +203,6 @@ $sync["Form"].Add_Closing({
|
||||
[System.GC]::Collect()
|
||||
})
|
||||
|
||||
|
||||
# Attach the event handler to the Click event
|
||||
$sync.CheckboxFilterClear.Add_Click({
|
||||
$sync.CheckboxFilter.Text = ""
|
||||
@ -264,8 +260,10 @@ $commonKeyEvents = {
|
||||
|
||||
$sync["Form"].Add_PreViewKeyDown($commonKeyEvents)
|
||||
|
||||
# adding some left mouse window move on drag capability
|
||||
$sync["Form"].Add_MouseLeftButtonDown({
|
||||
if ($sync["SettingsPopup"].IsOpen) {
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
}
|
||||
$sync["Form"].DragMove()
|
||||
})
|
||||
|
||||
@ -280,31 +278,36 @@ $sync["Form"].Add_MouseDoubleClick({
|
||||
}
|
||||
})
|
||||
|
||||
$sync["Form"].Add_ContentRendered({
|
||||
|
||||
foreach ($proc in (Get-Process | Where-Object { $_.MainWindowTitle -and $_.MainWindowTitle -like "*tit*" })) {
|
||||
if ($proc.Id -ne [System.IntPtr]::Zero) {
|
||||
Write-Debug "MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle) $($proc.MainWindowHandle)"
|
||||
$windowHandle = $proc.MainWindowHandle
|
||||
}
|
||||
$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 @"
|
||||
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
|
||||
@ -314,8 +317,29 @@ $sync["Form"].Add_ContentRendered({
|
||||
"@
|
||||
}
|
||||
|
||||
foreach ($proc in (Get-Process | Where-Object { $_.MainWindowTitle -and $_.MainWindowTitle -like "*titus*" })) {
|
||||
if ($proc.Id -ne [System.IntPtr]::Zero) {
|
||||
Write-Debug "MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle) $($proc.MainWindowHandle)"
|
||||
$windowHandle = $proc.MainWindowHandle
|
||||
}
|
||||
}
|
||||
|
||||
# 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
|
||||
[void][Window]::GetWindowRect($windowHandle, [ref]$rect)
|
||||
[Window]::GetWindowRect($windowHandle, [ref]$rect)
|
||||
$width = $rect.Right - $rect.Left
|
||||
$height = $rect.Bottom - $rect.Top
|
||||
|
||||
@ -347,6 +371,42 @@ $sync["Form"].Add_ContentRendered({
|
||||
|
||||
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."
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$sync["CheckboxFilter"].Add_TextChanged({
|
||||
@ -392,5 +452,50 @@ $sync["CheckboxFilter"].Add_TextChanged({
|
||||
|
||||
})
|
||||
|
||||
# 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
|
@ -5,6 +5,27 @@
|
||||
GitHub : https://github.com/ChrisTitusTech
|
||||
Version : #{replaceme}
|
||||
#>
|
||||
param (
|
||||
[switch]$Debug,
|
||||
[string]$Config,
|
||||
[switch]$Run
|
||||
)
|
||||
|
||||
# Set DebugPreference based on the -Debug switch
|
||||
if ($Debug) {
|
||||
$DebugPreference = "Continue"
|
||||
}
|
||||
|
||||
if ($Config) {
|
||||
$PARAM_CONFIG = $Config
|
||||
}
|
||||
|
||||
$PARAM_RUN = $false
|
||||
# Handle the -Run switch
|
||||
if ($Run) {
|
||||
Write-Host "Running config file tasks..."
|
||||
$PARAM_RUN = $true
|
||||
}
|
||||
|
||||
if (!(Test-Path -Path $ENV:TEMP)) {
|
||||
New-Item -ItemType Directory -Force -Path $ENV:TEMP
|
||||
@ -27,6 +48,7 @@ $currentPid = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$principal = new-object System.Security.Principal.WindowsPrincipal($currentPid)
|
||||
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
|
||||
|
||||
|
||||
if ($principal.IsInRole($adminRole))
|
||||
{
|
||||
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Admin)"
|
||||
|
Reference in New Issue
Block a user