Showing posts with label Powershell GUI. Show all posts
Showing posts with label Powershell GUI. Show all posts

Sunday, November 7, 2021

Enabling copy to Clipboard in a GUI Powershell

To copy a text to Clipboard in Powershell do the following:

$FullInfo = "This is the text that will be copied into memory
$FullInfo|set-clipboard

Adding a Listbox into a Powershell GUI

 To add a listbox into the GUI of the form do the following:

$cmbClaimType = New-Object Windows.Forms.combobox
$cmbClaimType.Size = New-Object System.Drawing.Size(230,30)
$cmbClaimType.AutoSize = $false
$cmbClaimType.Location = New-Object Drawing.Point 440,100
$cmbClaimType.Font = New-Object System.Drawing.Font("Arial",10,[System.Drawing.FontStyle]::Regular)
$cmbClaimType.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList

DropDownStyle has been set to a List so the users cannot add their own items

Adding a Checkbox into a Powershell GUI

 To add a checkbox into the GUI form do the following:

$chkAutoClear = New-Object System.Windows.Forms.CheckBox
$chkAutoClear.Text = "This is the name of the text shown"
$chkAutoClear.Location = New-Object System.Drawing.Size(440,140)
$chkAutoClear.Size = New-Object System.Drawing.Size(200,30)
$chkAutoClear.BackColor = "Transparent"
$chkAutoClear.Font = New-Object System.Drawing.Font("Arial",10,[System.Drawing.FontStyle]::Regular)
$chkAutoClear.Checked = $true

Size is x=200, y=30

Location is x=440, y=140