Here's a basic example of how you can use PowerShell to create a Windows Form GUI:
Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $form = New-Object System.Windows.Forms.Form $form.Text = "My First PowerShell GUI" $form.Size = New-Object System.Drawing.Size(300,200) $form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen $label = New-Object System.Windows.Forms.Label $label.Text = "Hello World" $label.Size = New-Object System.Drawing.Size(100,20) $label.Location = New-Object System.Drawing.Point(100,50) $form.Controls.Add($label) $form.ShowDialog()
This script will create a form with the text "My First PowerShell GUI" and a label with the text "Hello World". The form will have a size of 300x200 and will be positioned in the center of the screen. The ShowDialog
method will display the form and wait for the user to close it.
No comments:
Post a Comment