Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

Using the Graphical User Interface


If you are doing this as a script, you must have given yourself the permission execute scripts.

To start, you must load the library that holds the classes that are used for GUI programming. Remember, you cannot do a line break here. I only do it so that the whole line will visible.

Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089")

(Again, the above code is one single line.)

If you are unsure about versions and public keys, check your assembly folder in your Windows folder. If you right click on an assembly, and open the Properties dialog. There you highlight and copy the assambly information.

When the assembly is loaded, you can create a Form. This code will give it a caption and a size.

$myForm=New-Object Windows.Forms.Form
$myForm.Size=New-Object Drawing.Size(360,200)
$myForm.Text="Using Windows GUI from PowerShell"

The next thing I want to do, is to add a text label and a text input fileld on my form. I will position the text field under my label field.

$someLabel=New-Object Windows.Forms.Label
$someLabel.Text="Enter your name:"
$someLabel.Location=New-Object Drawing.Point(10,10)

$someField=New-Object Windows.Forms.TextBox
$someField.Size=New-Object Drawing.Size(300,16)
$someField.Location=New-Object Drawing.Point(10,30)


To show this form, call the ShowDialog function of the form object.


This is the result:

The next thing to do, is to react on user input.

Categories: PowerShell

Tags: PowerShell

One response to “Using the Graphical User Interface”

  1. Monex says:

    You ll want to start off by unzipping and copying the contents of the qForms. be amazed by how little actual JavaScript was needed in order to get the forms. Create a directory off the root of your web server to store the qForms API.

Leave a Reply

Your email address will not be published. Required fields are marked *

En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!


Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   |   |   |   Filmtips