Advertisement
Combreal

simpleGUI.ps1

Dec 22nd, 2022 (edited)
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [reflection.assembly]::loadwithpartialname(“System.Windows.Forms”) | Out-Null
  2. [reflection.assembly]::loadwithpartialname(“System.Drawing”) | Out-Null
  3.  
  4. $form = New-Object Windows.Forms.Form
  5. $form.text = "PowerShell WinForms Example"
  6.  
  7. $label = New-Object Windows.Forms.Label
  8. $label.Location = New-Object Drawing.Point 50,30
  9. $label.Size = New-Object Drawing.Point 200,15
  10. $label.text = "Enter your name and click the button"
  11.  
  12. $textfield = New-Object Windows.Forms.TextBox
  13. $textfield.Location = New-Object Drawing.Point 50,60
  14. $textfield.Size = New-Object Drawing.Point 200,30
  15.  
  16. $button = New-Object Windows.Forms.Button
  17. $button.text = "Greeting"
  18. $button.Location = New-Object Drawing.Point 100,90
  19.  
  20. $button.add_click({
  21.     $label.Text = "Hello " + $textfield.text
  22. })
  23.  
  24. $form.controls.add($button)
  25. $form.controls.add($label)
  26. $form.controls.add($textfield)
  27. $form.ShowDialog()| Out-Null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement