1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
|
Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing
$apps = @( @{Name="谷歌浏览器"; Path="C:\Program Files\Google\Chrome\Application\chrome.exe"; Icon="➲"}, @{Name="Edge 浏览器"; Path="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"; Icon="➲"}, @{Name="微信"; Path="D:\Program Files\Tencent\Weixin\Weixin.exe"; Icon="☏"}, @{Name="QQ"; Path="D:\Program Files (x86)\Tencent\QQ\Bin\QQ.exe"; Icon="♫"}, @{Name="VSCode"; Path="D:\Program Files\VSCode\Code.exe"; Icon="📄"}, @{Name="有道云笔记"; Path="D:\Program Files\ynote-desktop\有道云笔记.exe"; Icon="⚙"}, @{Name="Notepad++"; Path="E:\常用软件包\npp.8.6.7.portable.x64\notepad++.exe"; Icon="✎"}, @{Name="Photoshop"; Path="C:\Program Files\Adobe\Photoshop\photoshop.exe"; Icon="🎨"}, @{Name="Excel"; Path="C:\Program Files\Microsoft Office\Office16\EXCEL.EXE"; Icon="★"}, @{Name="Word"; Path="C:\Program Files\Microsoft Office\Office16\WINWORD.EXE"; Icon="♦"}, @{Name="PowerPoint"; Path="C:\Program Files\Microsoft Office\Office16\POWERPNT.EXE"; Icon="♣"}, @{Name="Teams"; Path="C:\Program Files\Microsoft Teams\teams.exe"; Icon="嘻嘻"}, @{Name="Slack"; Path="C:\Program Files\Slack\slack.exe"; Icon="💼"}, @{Name="Discord"; Path="C:\Program Files\Discord\Discord.exe"; Icon="⚔"}, @{Name="Spotify"; Path="C:\Program Files\Spotify\Spotify.exe"; Icon="♫"}, @{Name="计算器"; Path="C:\Windows\System32\calc.exe"; Icon="℗"}, @{Name="画图"; Path="C:\Windows\System32\mspaint.exe"; Icon="❂"}, @{Name="记事本"; Path="C:\Windows\System32\notepad.exe"; Icon="📄"} )
$form = New-Object System.Windows.Forms.Form $form.Text = "🌞 向阳的应用启动面板 v4.1" $form.StartPosition = "CenterScreen" $form.Size = New-Object System.Drawing.Size(850, 600) $form.BackColor = [System.Drawing.Color]::FromArgb(245, 249, 255) $form.TopMost = $false $form.FormBorderStyle = "FixedDialog" $form.MaximizeBox = $false $form.MinimizeBox = $true
$headerPanel = New-Object System.Windows.Forms.Panel $headerPanel.Size = New-Object System.Drawing.Size(810, 90) $headerPanel.Location = New-Object System.Drawing.Point(20, 15) $headerPanel.BackColor = [System.Drawing.Color]::FromArgb(74, 107, 255) $headerPanel.ForeColor = [System.Drawing.Color]::White $form.Controls.Add($headerPanel)
$headerPanel.Add_Paint({ param($sender, $e) $brush = New-Object System.Drawing.Drawing2D.LinearGradientBrush( $sender.ClientRectangle, [System.Drawing.Color]::FromArgb(74, 107, 255), [System.Drawing.Color]::FromArgb(119, 146, 255), [System.Drawing.Drawing2D.LinearGradientMode]::Horizontal ) $e.Graphics.FillRectangle($brush, $sender.ClientRectangle) $brush.Dispose() })
$titleLabel = New-Object System.Windows.Forms.Label $titleLabel.Text = "应用启动面板" $titleLabel.Font = New-Object System.Drawing.Font("Microsoft YaHei", 16, [System.Drawing.FontStyle]::Bold) $titleLabel.ForeColor = [System.Drawing.Color]::White $titleLabel.Size = New-Object System.Drawing.Size(810, 40) $titleLabel.Location = New-Object System.Drawing.Point(0, 15) $titleLabel.TextAlign = "MiddleCenter" $headerPanel.Controls.Add($titleLabel)
$subtitleLabel = New-Object System.Windows.Forms.Label $subtitleLabel.Text = "选择您要启动的应用程序" $subtitleLabel.Font = New-Object System.Drawing.Font("Microsoft YaHei", 10, [System.Drawing.FontStyle]::Regular) $subtitleLabel.ForeColor = [System.Drawing.Color]::FromArgb(230, 230, 255) $subtitleLabel.Size = New-Object System.Drawing.Size(810, 25) $subtitleLabel.Location = New-Object System.Drawing.Point(0, 55) $subtitleLabel.TextAlign = "MiddleCenter" $headerPanel.Controls.Add($subtitleLabel)
$scrollPanel = New-Object System.Windows.Forms.Panel $scrollPanel.Size = New-Object System.Drawing.Size(810, 350) $scrollPanel.Location = New-Object System.Drawing.Point(20, 120) $scrollPanel.BackColor = [System.Drawing.Color]::White $scrollPanel.BorderStyle = "FixedSingle" $scrollPanel.AutoScroll = $true $form.Controls.Add($scrollPanel)
$checkboxes = @() $columnCount = 3 $itemWidth = 200 $itemHeight = 50 $margin = 15
for ($i = 0; $i -lt $apps.Count; $i++) { $app = $apps[$i] $row = [Math]::Floor($i / $columnCount) $column = $i % $columnCount $x = $margin + ($column * $itemWidth) $y = $margin + ($row * $itemHeight) $itemPanel = New-Object System.Windows.Forms.Panel $itemPanel.Size = New-Object System.Drawing.Size(($itemWidth - 25), 40) $itemPanel.Location = New-Object System.Drawing.Point($x, $y) $itemPanel.BackColor = [System.Drawing.Color]::FromArgb(250, 252, 255) $itemPanel.BorderStyle = "FixedSingle" $itemPanel.Cursor = [System.Windows.Forms.Cursors]::Hand $itemPanel.Add_MouseEnter({ $this.BackColor = [System.Drawing.Color]::FromArgb(240, 245, 255) $this.BorderStyle = "FixedSingle" }) $itemPanel.Add_MouseLeave({ if (-not $this.Controls[0].Checked) { $this.BackColor = [System.Drawing.Color]::FromArgb(250, 252, 255) } }) $cb = New-Object System.Windows.Forms.CheckBox $cb.Text = " $($app.Icon) $($app.Name)" $cb.Tag = $app.Path $cb.Font = New-Object System.Drawing.Font("Microsoft YaHei", 9.5, [System.Drawing.FontStyle]::Regular) $cb.Location = New-Object System.Drawing.Point(8, 10) $cb.AutoSize = $true $cb.BackColor = [System.Drawing.Color]::Transparent $cb.Cursor = [System.Windows.Forms.Cursors]::Hand $cb.Add_CheckedChanged({ if ($this.Checked) { $this.Parent.BackColor = [System.Drawing.Color]::FromArgb(230, 240, 255) } else { $this.Parent.BackColor = [System.Drawing.Color]::FromArgb(250, 252, 255) } }) $itemPanel.Controls.Add($cb) $scrollPanel.Controls.Add($itemPanel) $checkboxes += $cb }
$totalRows = [Math]::Ceiling($apps.Count / $columnCount) $scrollPanel.Height = [Math]::Min(350, ($totalRows * $itemHeight + 2 * $margin))
$buttonPanel = New-Object System.Windows.Forms.Panel $buttonPanel.Size = New-Object System.Drawing.Size(810, 80) $buttonPanel.Location = New-Object System.Drawing.Point(20, ($scrollPanel.Location.Y + $scrollPanel.Height + 20)) $buttonPanel.BackColor = [System.Drawing.Color]::Transparent $form.Controls.Add($buttonPanel)
$launchButton = New-Object System.Windows.Forms.Button $launchButton.Text = "🚀 启动选中程序" $launchButton.Font = New-Object System.Drawing.Font("Microsoft YaHei", 11, [System.Drawing.FontStyle]::Bold) $launchButton.Size = New-Object System.Drawing.Size(200, 45) $launchButton.Location = New-Object System.Drawing.Point(150, 15) $launchButton.BackColor = [System.Drawing.Color]::FromArgb(74, 107, 255) $launchButton.ForeColor = [System.Drawing.Color]::White $launchButton.FlatStyle = "Flat" $launchButton.FlatAppearance.BorderSize = 0 $launchButton.Cursor = [System.Windows.Forms.Cursors]::Hand
$launchButton.Add_MouseEnter({ $this.BackColor = [System.Drawing.Color]::FromArgb(30, 144, 255) })
$launchButton.Add_MouseLeave({ $this.BackColor = [System.Drawing.Color]::FromArgb(74, 107, 255) })
$launchButton.Add_Click({ $selected = $checkboxes | Where-Object { $_.Checked } if ($selected.Count -eq 0) { [System.Windows.Forms.MessageBox]::Show("请至少选择一个应用程序!", "提示", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information) return }
$notFound = @() $successCount = 0 foreach ($item in $selected) { $path = $item.Tag if (Test-Path $path) { try { Start-Process -FilePath $path -ErrorAction Stop $successCount++ } catch { $notFound += "$($item.Text.Trim()) (启动失败)" } } else { $notFound += "$($item.Text.Trim()) (文件不存在)" } Start-Sleep -Milliseconds 100 }
if ($notFound.Count -gt 0) { [System.Windows.Forms.MessageBox]::Show("以下程序启动失败:`n`n" + ($notFound -join "`n"), "⚠️ 启动失败", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Warning) } else { [System.Windows.Forms.MessageBox]::Show("✅ 已成功启动 $successCount 个应用!", "完成", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information) $form.WindowState = [System.Windows.Forms.FormWindowState]::Minimized } }) $buttonPanel.Controls.Add($launchButton)
$form.Height = $buttonPanel.Location.Y + $buttonPanel.Height + 50
[void]$form.ShowDialog()
|