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 |
$buttons_functionslist=@( $json=(Invoke-WebRequest -Uri 'https://www.jesusninoc.com/wp-json/wp/v2/categories').content | ConvertFrom-JSON $json.name ) $buttons_functionbuttoncount = $buttons_functionslist.count $loop = 0 #Formulario $Form = New-Object System.Windows.Forms.Form $Form.Text="Formulario" $Form.Size=New-Object System.Drawing.Size(500,500) $Form.StartPosition="CenterScreen" while($loop -lt $buttons_functionbuttoncount) { $thisbutton = New-Object System.Windows.Forms.Button [string]$thisbuttonname = $buttons_functionslist[$loop] $thisbutton.Text = $thisbuttonname $thisbutton.size = New-Object System.Drawing.Size(100,20) $thisbutton.Location = New-Object System.Drawing.Size(200,(20*$loop+1)) $thisbutton.Add_Click({ Write-Host $this.Text }) $Form.Controls.Add($thisbutton) $loop += 1 } $Form.ShowDialog() |