2021/04/10 #FormとButtonとLabelとTextboxを表示

皆様おはようございます、

#猫でもできるPowerShell(備忘録)

#FormとButtonとLabelとTextboxを表示

 

<# 元ネタ

https://www.atmarkit.co.jp/ait/articles/0607/26/news118_3.html

#>

$form = New-Object System.Windows.Forms.Form

 

$button = New-Object System.Windows.Forms.Button

$button.Location = New-Object System.Drawing.Point(10, 100)

$button.Text = "押すな"

$button.add_Click({ $label.Text = "Get-Date -Format g"; $textbox.text

= (iex $label.Text) })

 

$label = New-Object System.Windows.Forms.Label

$label.Location = New-Object System.Drawing.Point(10, 10)

$label.Size = New-Object System.Drawing.Size(180,120)

 

$textBox = New-Object System.Windows.Forms.TextBox

$textBox.Location = New-Object System.Drawing.Point(10,50)

$textBox.Size = New-Object System.Drawing.Size(180,120)

 

$form.Controls.Add($textBox)

$form.Controls.AddRange*1

[System.Windows.Forms.Application]::Run($form)

 

 

f:id:TPTPTb:20210410235617p:plain



昨日の結果にテキストボックスを追加し、少し面白くなってきています

ではまた;

*1:$button, $label