Pull The Trigger 2003

3 months ago
4

# ===========================================================
# Neon Glow Themes Portable App - Installer.ps1
# ===========================================================
$ErrorActionPreference = "Stop"
$RootDir = "$env:PUBLIC\NeonGlowThemes"
$Bin = Join-Path $RootDir "bin"
$Themes = Join-Path $RootDir "themes"
$Tasks = Join-Path $RootDir "tasks"

# --- Step 0: Ensure folders exist ---
foreach ($dir in @($RootDir,$Bin,$Themes,$Tasks)) {
if (-not (Test-Path $dir)) { New-Item $dir -ItemType Directory -Force | Out-Null }
}

# --- Step 1: Ensure dependencies ---
Function Ensure-Winget {
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
Write-Host "Winget missing → Installing App Installer..."
Start-Process "ms-windows-store://pdp/?productid=9NBLGGH4NNS1" -Wait
Write-Host "Install App Installer and re-run script"; exit
}
}
Function Ensure-Python {
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
Write-Host "Python missing → Installing via Winget..."
winget install --id Python.Python.3 --source winget -e --silent
}
}
Function Ensure-PowerShell {
if ($PSVersionTable.PSVersion.Major -lt 7) {
Write-Host "PowerShell 7+ missing → Installing via Winget..."
winget install --id Microsoft.Powershell --source winget -e --silent
Write-Host "Re-run script in PowerShell 7+"; exit
}
}
Function Ensure-VSCode {
if (-not (Get-Command code -ErrorAction SilentlyContinue)) {
Write-Host "VS Code missing → Installing via Winget..."
winget install --id Microsoft.VisualStudioCode --source winget -e --silent
}
}
Ensure-Winget; Ensure-Python; Ensure-PowerShell; Ensure-VSCode

# --- Step 2: High Contrast Glow Scanner ---
$GlowHC_Scanner = @"
param([string]`$Source='$env:LOCALAPPDATA\Microsoft\Windows\Themes',[string]`$OutDir='$Themes',[string]`$GlowHex='#00FF00')
if (-not (Test-Path `$OutDir)) { New-Item `$OutDir -ItemType Directory | Out-Null }
Function HexRGB(`$h){ `$h=`$h.TrimStart('#'); @{ r=[Convert]::ToInt32(`$h.Substring(0,2),16); g=[Convert]::ToInt32(`$h.Substring(2,2),16); b=[Convert]::ToInt32(`$h.Substring(4,2),16) } }
`$rgb = HexRGB `$GlowHex
Get-ChildItem `$Source -Filter *.contrasttheme | ForEach-Object {
`$json = Get-Content `$_.FullName -Raw | ConvertFrom-Json
foreach (`$k in `$json.theme.colors.PSObject.Properties.Name) { `$json.theme.colors.`$k = @{ r=`$rgb.r; g=`$rgb.g; b=`$rgb.b } }
`$out = Join-Path `$OutDir ("Neon-" + `$_.BaseName + ".contrasttheme")
`$json | ConvertTo-Json -Depth 20 | Set-Content `$out -Encoding UTF8
Write-Host "Created `$out"
}
"@
Set-Content -Path (Join-Path $Bin "GlowHC_Scanner.ps1") -Value $GlowHC_Scanner -Encoding UTF8

# --- Step 3: Apply + Force High Contrast Theme ---
$GlowHC_Apply = @"
param([string]`$Theme)
`$hcKey='HKCU:\Control Panel\Accessibility\HighContrast'; New-Item `$hcKey -Force | Out-Null; Set-ItemProperty `$hcKey Flags 1; Set-ItemProperty `$hcKey HighContrastScheme `$Theme
`$themeKey='HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes'; Set-ItemProperty `$themeKey CurrentTheme `$Theme
Start-Process explorer.exe
"@
Set-Content -Path (Join-Path $Bin "GlowHC_Apply.ps1") -Value $GlowHC_Apply -Encoding UTF8

# --- Step 4: Lock Engine ---
$GlowHC_Lock = @"
param([string]`$ThemePath)
`$paths=@{HC='HKCU:\Control Panel\Accessibility\HighContrast';TH='HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes';DWM='HKCU:\Software\Microsoft\Windows\DWM'}
while(`$true){
Set-ItemProperty `$paths.HC Flags 1 -ErrorAction SilentlyContinue
Set-ItemProperty `$paths.TH CurrentTheme `$ThemePath -ErrorAction SilentlyContinue
Start-Sleep 2
}
"@
Set-Content -Path (Join-Path $Bin "GlowHC_Lock.ps1") -Value $GlowHC_Lock -Encoding UTF8

# --- Step 5: Scheduled Task ---
$TaskXml = Join-Path $Tasks "GlowHC_Enforce.xml"
$TaskCmd = "powershell -ExecutionPolicy Bypass -File `"$Bin\GlowHC_Lock.ps1`" `"$Themes\Neon-Green.contrasttheme`""
if (-not (Get-ScheduledTask -TaskName "GlowHC_Enforce" -ErrorAction SilentlyContinue)) {
schtasks /create /tn "GlowHC_Enforce" /sc onlogon /rl highest /tr $TaskCmd
}

# --- Step 6: ANSI + WinForms Launcher ---
$GlowHC_Launcher = @"
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
`$form=New-Object System.Windows.Forms.Form
`$form.Text='Neon Glow Themes'
`$form.Size=New-Object System.Drawing.Size(500,300)
`$btnGreen=New-Object System.Windows.Forms.Button
`$btnGreen.Text='Glow Green'; `$btnGreen.Location=New-Object System.Drawing.Point(20,50)
`$btnGreen.Add_Click({Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File `"$Bin\GlowHC_Apply.ps1`" `"$Themes\Neon-Green.contrasttheme`"'})
`$btnRed=New-Object System.Windows.Forms.Button
`$btnRed.Text='Glow Red'; `$btnRed.Location=New-Object System.Drawing.Point(150,50)
`$btnRed.Add_Click({Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File `"$Bin\GlowHC_Apply.ps1`" `"$Themes\Neon-Red.contrasttheme`"'})
`$btnBlue=New-Object System.Windows.Forms.Button
`$btnBlue.Text='Glow Blue'; `$btnBlue.Location=New-Object System.Drawing.Point(280,50)
`$btnBlue.Add_Click({Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File `"$Bin\GlowHC_Apply.ps1`" `"$Themes\Neon-Blue.contrasttheme`"'})
`$form.Controls.AddRange(@(`$btnGreen,`$btnRed,`$btnBlue))
[System.Windows.Forms.Application]::EnableVisualStyles()
[System.Windows.Forms.Application]::Run(`$form)
"@
Set-Content -Path (Join-Path $Bin "GlowHC_Launcher.ps1") -Value $GlowHC_Launcher -Encoding UTF8

# --- Step 7: Build ANSI Console Launcher ---
$GlowHC_Cmd = @"
@echo off
title Neon Glow Themes
echo 1 - Glow Green
echo 2 - Glow Red
echo 3 - Glow Blue
set /p CH=Choice:
if %CH%==1 powershell -NoProfile -ExecutionPolicy Bypass -File `"$Bin\GlowHC_Apply.ps1`" `"$Themes\Neon-Green.contrasttheme`"
if %CH%==2 powershell -NoProfile -ExecutionPolicy Bypass -File `"$Bin\GlowHC_Apply.ps1`" `"$Themes\Neon-Red.contrasttheme`"
if %CH%==3 powershell -NoProfile -ExecutionPolicy Bypass -File `"$Bin\GlowHC_Apply.ps1`" `"$Themes\Neon-Blue.contrasttheme`"
"@
Set-Content -Path (Join-Path $RootDir "GlowHC.cmd") -Value $GlowHC_Cmd -Encoding UTF8

Write-Host "✅ Neon Glow Themes Portable App installed at $RootDir"
Write-Host "Run `$RootDir\GlowHC.cmd` or `$Bin\GlowHC_Launcher.ps1` to launch."

Loading comments...