@@ -72,55 +72,60 @@ function Get-WingetAppInfo ($SearchApp){
7272}
7373
7474function Get-InstallGUI {
75+
76+ # # FORM ##
77+
7578 Add-Type - AssemblyName System.Windows.Forms
7679 Add-Type - AssemblyName System.Drawing
7780
78- $AppSelect = New-Object System.Windows.Forms.Form
81+ $WiguiForm = New-Object System.Windows.Forms.Form
7982
80- $Cancel = New-Object System.Windows.Forms.Button
81- $OK = New-Object System.Windows.Forms.Button
82- $Search = New-Object System.Windows.Forms.Button
83- $SearchText = New-Object System.Windows.Forms.TextBox
83+ $CancelButton = New-Object System.Windows.Forms.Button
84+ $InstallButton = New-Object System.Windows.Forms.Button
85+ $SearchButton = New-Object System.Windows.Forms.Button
86+ $SearchTextBox = New-Object System.Windows.Forms.TextBox
8487 $SearchLabel = New-Object System.Windows.Forms.Label
85- $SearchResult = New-Object System.Windows.Forms.ComboBox
86- $Submit = New-Object System.Windows.Forms.Button
88+ $SubmitComboBox = New-Object System.Windows.Forms.ComboBox
89+ $SubmitButton = New-Object System.Windows.Forms.Button
8790 $SubmitLabel = New-Object System.Windows.Forms.Label
88- $AppList = New-Object System.Windows.Forms.ListBox
8991 $AppListLabel = New-Object System.Windows.Forms.Label
92+ $AppListBox = New-Object System.Windows.Forms.ListBox
93+ $RemoveButton = New-Object System.Windows.Forms.Button
94+ $SaveListButton = New-Object System.Windows.Forms.Button
9095 #
91- # Cancel
96+ # CancelButton
9297 #
93- $Cancel .Location = New-Object System.Drawing.Point(397 , 526 )
94- $Cancel .Name = " Cancel "
95- $Cancel .Size = New-Object System.Drawing.Size(75 , 23 )
96- $Cancel .TabIndex = 0
97- $Cancel .Text = " Cancel"
98- $Cancel .UseVisualStyleBackColor = $true
98+ $CancelButton .Location = New-Object System.Drawing.Point(397 , 526 )
99+ $CancelButton .Name = " CancelButton "
100+ $CancelButton .Size = New-Object System.Drawing.Size(75 , 23 )
101+ $CancelButton .TabIndex = 0
102+ $CancelButton .Text = " Cancel"
103+ $CancelButton .UseVisualStyleBackColor = $true
99104 #
100- # OK
105+ # InstallButton
101106 #
102- $OK .Location = New-Object System.Drawing.Point(316 , 526 )
103- $OK .Name = " OK "
104- $OK .Size = New-Object System.Drawing.Size(75 , 23 )
105- $OK .TabIndex = 1
106- $OK .Text = " OK "
107- $OK .UseVisualStyleBackColor = $true
107+ $InstallButton .Location = New-Object System.Drawing.Point(316 , 526 )
108+ $InstallButton .Name = " InstallButton "
109+ $InstallButton .Size = New-Object System.Drawing.Size(75 , 23 )
110+ $InstallButton .TabIndex = 1
111+ $InstallButton .Text = " Install "
112+ $InstallButton .UseVisualStyleBackColor = $true
108113 #
109- # Search
114+ # SearchButton
110115 #
111- $Search .Location = New-Object System.Drawing.Point(397 , 34 )
112- $Search .Name = " Search "
113- $Search .Size = New-Object System.Drawing.Size(75 , 23 )
114- $Search .TabIndex = 2
115- $Search .Text = " Search"
116- $Search .UseVisualStyleBackColor = $true
116+ $SearchButton .Location = New-Object System.Drawing.Point(397 , 34 )
117+ $SearchButton .Name = " SearchButton "
118+ $SearchButton .Size = New-Object System.Drawing.Size(75 , 23 )
119+ $SearchButton .TabIndex = 2
120+ $SearchButton .Text = " Search"
121+ $SearchButton .UseVisualStyleBackColor = $true
117122 #
118- # SearchText
123+ # SearchTextBox
119124 #
120- $SearchText .Location = New-Object System.Drawing.Point(12 , 36 )
121- $SearchText .Name = " SearchText "
122- $SearchText .Size = New-Object System.Drawing.Size(379 , 20 )
123- $SearchText .TabIndex = 3
125+ $SearchTextBox .Location = New-Object System.Drawing.Point(12 , 36 )
126+ $SearchTextBox .Name = " SearchTextBox "
127+ $SearchTextBox .Size = New-Object System.Drawing.Size(379 , 20 )
128+ $SearchTextBox .TabIndex = 3
124129 #
125130 # SearchLabel
126131 #
@@ -131,22 +136,22 @@ function Get-InstallGUI {
131136 $SearchLabel.TabIndex = 4
132137 $SearchLabel.Text = " Search an app:"
133138 #
134- # SearchResult
139+ # SubmitComboBox
135140 #
136- $SearchResult .FormattingEnabled = $true
137- $SearchResult .Location = New-Object System.Drawing.Point(13 , 91 )
138- $SearchResult .Name = " SearchResult "
139- $SearchResult .Size = New-Object System.Drawing.Size(378 , 21 )
140- $SearchResult .TabIndex = 5
141+ $SubmitComboBox .FormattingEnabled = $true
142+ $SubmitComboBox .Location = New-Object System.Drawing.Point(13 , 91 )
143+ $SubmitComboBox .Name = " SubmitComboBox "
144+ $SubmitComboBox .Size = New-Object System.Drawing.Size(378 , 21 )
145+ $SubmitComboBox .TabIndex = 5
141146 #
142- # Submit
147+ # SubmitButton
143148 #
144- $Submit .Location = New-Object System.Drawing.Point(397 , 90 )
145- $Submit .Name = " Submit "
146- $Submit .Size = New-Object System.Drawing.Size(75 , 23 )
147- $Submit .TabIndex = 6
148- $Submit .Text = " Submit"
149- $Submit .UseVisualStyleBackColor = $true
149+ $SubmitButton .Location = New-Object System.Drawing.Point(397 , 90 )
150+ $SubmitButton .Name = " SubmitButton "
151+ $SubmitButton .Size = New-Object System.Drawing.Size(75 , 23 )
152+ $SubmitButton .TabIndex = 6
153+ $SubmitButton .Text = " Submit"
154+ $SubmitButton .UseVisualStyleBackColor = $true
150155 #
151156 # SubmitLabel
152157 #
@@ -157,13 +162,6 @@ function Get-InstallGUI {
157162 $SubmitLabel.TabIndex = 7
158163 $SubmitLabel.Text = " Select the matching Winget AppID:"
159164 #
160- # AppList
161- #
162- $AppList.Location = New-Object System.Drawing.Point(12 , 152 )
163- $AppList.Name = " AppList"
164- $AppList.Size = New-Object System.Drawing.Size(460 , 368 )
165- $AppList.TabIndex = 8
166- #
167165 # AppListLabel
168166 #
169167 $AppListLabel.AutoSize = $true
@@ -173,63 +171,116 @@ function Get-InstallGUI {
173171 $AppListLabel.TabIndex = 9
174172 $AppListLabel.Text = " Current Application list:"
175173 #
176- # AppSelect
174+ # AppListBox
175+ #
176+ $AppListBox.FormattingEnabled = $true
177+ $AppListBox.Location = New-Object System.Drawing.Point(12 , 152 )
178+ $AppListBox.Name = " AppListBox"
179+ $AppListBox.Size = New-Object System.Drawing.Size(379 , 355 )
180+ $AppListBox.TabIndex = 11
181+ #
182+ # RemoveButton
183+ #
184+ $RemoveButton.Location = New-Object System.Drawing.Point(397 , 151 )
185+ $RemoveButton.Name = " RemoveButton"
186+ $RemoveButton.Size = New-Object System.Drawing.Size(75 , 23 )
187+ $RemoveButton.TabIndex = 12
188+ $RemoveButton.Text = " Remove"
189+ $RemoveButton.UseVisualStyleBackColor = $true
177190 #
178- $AppSelect.ClientSize = New-Object System.Drawing.Size(484 , 561 )
179- $AppSelect.Controls.Add ($AppListLabel )
180- $AppSelect.Controls.Add ($AppList )
181- $AppSelect.Controls.Add ($SubmitLabel )
182- $AppSelect.Controls.Add ($Submit )
183- $AppSelect.Controls.Add ($SearchResult )
184- $AppSelect.Controls.Add ($SearchLabel )
185- $AppSelect.Controls.Add ($SearchText )
186- $AppSelect.Controls.Add ($Search )
187- $AppSelect.Controls.Add ($OK )
188- $AppSelect.Controls.Add ($Cancel )
189- $AppSelect.FormBorderStyle = [System.Windows.Forms.FormBorderStyle ]::FixedSingle
190- $AppSelect.Name = " AppSelect"
191- $AppSelect.Text = " Winget-Install"
191+ # SaveListButton
192+ #
193+ $SaveListButton.Location = New-Object System.Drawing.Point(12 , 526 )
194+ $SaveListButton.Name = " SaveListButton"
195+ $SaveListButton.Size = New-Object System.Drawing.Size(130 , 23 )
196+ $SaveListButton.TabIndex = 13
197+ $SaveListButton.Text = " Save list to File"
198+ $SaveListButton.UseVisualStyleBackColor = $true
199+ #
200+ # WiguiForm
201+ #
202+ $WiguiForm.ClientSize = New-Object System.Drawing.Size(484 , 561 )
203+ $WiguiForm.Controls.Add ($SaveListButton )
204+ $WiguiForm.Controls.Add ($RemoveButton )
205+ $WiguiForm.Controls.Add ($AppListBox )
206+ $WiguiForm.Controls.Add ($AppListLabel )
207+ $WiguiForm.Controls.Add ($SubmitLabel )
208+ $WiguiForm.Controls.Add ($SubmitButton )
209+ $WiguiForm.Controls.Add ($SubmitComboBox )
210+ $WiguiForm.Controls.Add ($SearchLabel )
211+ $WiguiForm.Controls.Add ($SearchTextBox )
212+ $WiguiForm.Controls.Add ($SearchButton )
213+ $WiguiForm.Controls.Add ($InstallButton )
214+ $WiguiForm.Controls.Add ($CancelButton )
215+ $WiguiForm.FormBorderStyle = [System.Windows.Forms.FormBorderStyle ]::FixedSingle
216+ $WiguiForm.Name = " WiguiForm"
217+ $WiguiForm.ShowIcon = $false
218+ $WiguiForm.Text = " Winget-Install-GUI (WiGui v1.1.0)"
219+
220+
192221
222+ # # ACTIONS ##
193223
194224 # On clicks
195- $Search.add_click ({
196- $SearchResult.Items.Clear ()
197- $List = Get-WingetAppInfo $SearchText.Text
225+
226+ $SearchButton.add_click ({
227+ $SubmitComboBox.Items.Clear ()
228+ $List = Get-WingetAppInfo $SearchTextBox.Text
198229 foreach ($L in $List ){
199- $SearchResult .Items.Add ($L.ID )
230+ $SubmitComboBox .Items.Add ($L.ID )
200231 }
201- $SearchResult .SelectedIndex = 0
232+ $SubmitComboBox .SelectedIndex = 0
202233 })
203234
204- $Submit.add_click ({
205- $AddAppToList = $SearchResult.Text
206- $AppList.Items
207- if ($AddAppToList -ne " " -and $AppList.Items -notcontains $AddAppToList ){
208- $AppList.Items.Add ($AddAppToList )
235+ $SubmitButton.add_click ({
236+ $AddAppToList = $SubmitComboBox.Text
237+ if ($AddAppToList -ne " " -and $AppListBox.Items -notcontains $AddAppToList ){
238+ $AppListBox.Items.Add ($AddAppToList )
209239 }
210240 })
211241
212- $Cancel.add_click ({
213- $AppSelect.Close ()
242+ $RemoveButton.add_click ({
243+ $RemoveAppFromList = $AppListBox.SelectedItem
244+ $AppListBox.Items.Remove ($RemoveAppFromList )
245+ })
246+
247+ $SaveListButton.add_click ({
248+ Add-Type - AssemblyName System.Windows.Forms
249+ $SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog
250+ $SaveFileDialog.Filter = " txt files (*.txt)|*.txt|All files (*.*)|*.*"
251+ $response = $SaveFileDialog.ShowDialog ( ) # $response can return OK or Cancel
252+ if ( $response -eq ' OK' ) {
253+ $AppListBox.Items | Out-File $SaveFileDialog.FileName - Append
254+ Write-Host ' File saved:' $SaveFileDialog.FileName
255+ }
256+ })
257+
258+ $CancelButton.add_click ({
259+ $WiguiForm.Close ()
214260 })
215261
216- $OK.add_click ({
217- $Script :AppToInstall = $AppList.Items
218- $AppSelect.Close ()
262+ $InstallButton.add_click ({
263+ if ($AppListBox.Items ){
264+ $Script :AppToInstall = $AppListBox.Items
265+ $WiguiForm.Close ()
266+ }
219267 })
220268
221- $AppSelect .ShowDialog () | Out-Null
269+ $WiguiForm .ShowDialog () | Out-Null
222270}
223271
224272
225273# # Main ##
274+ $Script :AppToInstall = $null
226275
227276Get-InstallGUI
228277
229- Write-Host " Selected Apps to install : $AppToInstall "
278+ if ( $AppToInstall ){
230279
231- foreach ($App in $AppToInstall ){
232- & $Winget install - e -- id $App - h -- accept- package- agreements -- accept- source- agreements
233- }
280+ Write-Host " Selected Apps to install : $AppToInstall "
281+
282+ foreach ($App in $AppToInstall ){
283+ & $Winget install - e -- id $App - h -- accept- package- agreements -- accept- source- agreements
284+ }
234285
235- Timeout 10
286+ }
0 commit comments