Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
- $mGUI = new-module -ascustomobject {
- function GuiCreate()
- {
- Param (
- [string]$title,
- [int]$x,
- [int]$y,
- [int]$w,
- [int]$h
- );
- $o = new-object Windows.Forms.Form
- $o.Text = $title
- $o.Left = $x
- $o.Top = $y
- $o.Width = $w
- $o.Height = $h
- return ,$o
- };
- function ButtonCreate()
- {
- Param (
- [string]$text,
- [int]$x,
- [int]$y,
- [int]$w,
- [int]$h,
- [ScriptBlock]$clickFunc
- );
- $o = new-object Windows.Forms.Button
- $o.Text = $text
- $o.Left = $x
- $o.Top = $y
- $o.Width = $w
- $o.Height = $h
- $o.Add_Click($clickFunc)
- return ,$o
- };
- function CtrlAdd()
- {
- Param (
- [PsObject]$oGui,
- [PsObject]$oCtrl
- );
- $oGui.Controls.Add($oCtrl)
- }
- }
- $gui = $mGUI.GuiCreate('Test', 100, 100, 600, 400)
- $btn = $mGUI.ButtonCreate('OK', 100, 100, 50, 25, {$gui.close()})
- $mGUI.CtrlAdd($gui, $btn)
- $gui.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement