PS Function – Copy contents of form textbox to clipboard

#region FUNCTION #3 Copy to clipboard
Function ClipMe() {
[System.Windows.Forms.Clipboard]::SetText($ST.Text.Trim())
}
#endregion FUNCTION Copy to clipboard

NB: In this example my form has a textbox called $ST – The function captures the text content and trims it to remove any unwanted white space.

$ST = New-Object System.Windows.Forms.Textbox
$ST.Size = New-Object System.Drawing.Size(135,100)
$ST.ReadOnly = $true
$ST.Font = “Segoe UI,16”
$ST.Location = “150,120”
$ST.TextAlign = “Center”
$groupConvert.Controls.Add($ST)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s