Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Write a powershell script , also add 26 new buttons. Each of the 26 buttons represent alphabets a to z. When 1 of the 26 buttons is clicked , the corresponding alphabet is shown in the GUI.
- # Here's a PowerShell script that creates a GUI with 26 buttons representing the letters A to Z. When a button is clicked, the corresponding letter is displayed in a label:
- Add-Type -AssemblyName System.Windows.Forms
- # Create the form
- $form = New-Object System.Windows.Forms.Form
- $form.Text = "Alphabet Buttons"
- $form.Size = New-Object System.Drawing.Size(300, 200)
- $form.StartPosition = "CenterScreen"
- # Create the label to display the selected letter
- $label = New-Object System.Windows.Forms.Label
- $label.Location = New-Object System.Drawing.Point(100, 50)
- $label.Size = New-Object System.Drawing.Size(100, 50)
- $form.Controls.Add($label)
- # Create the buttons for each letter
- $letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- $buttonX = 20
- $buttonY = 100
- $buttonWidth = 20
- $buttonHeight = 20
- foreach ($letter in $letters.ToCharArray()) {
- $button = New-Object System.Windows.Forms.Button
- $button.Location = New-Object System.Drawing.Point($buttonX, $buttonY)
- $button.Size = New-Object System.Drawing.Size($buttonWidth, $buttonHeight)
- $button.Text = $letter
- $button.Add_Click({
- $label.Text = $button.Text
- })
- $form.Controls.Add($button)
- $buttonX += $buttonWidth + 5
- }
- # Show the form
- $form.ShowDialog() | Out-Null
- This script creates a form with a label and 26 buttons, one for each letter of the alphabet. When a button is clicked, the corresponding letter is displayed in the label. You can customize the size and position of the form, label, and buttons by modifying the values in the script.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement