• EnglishSpanishGermanFrenchPolishChinese (Traditional)


EnglishSpanishGermanFrenchPolishChinese (Traditional)

Operating systems, scripting, PowerShell and security

Operating systems, software development, scripting, PowerShell tips, network and security

Menú principal
  • Categorías
  • Cursos
  • Libro de PowerShell
  • Lo mejor
  • Lo último
  • Proyectos
  • Contactar
Ir al contenido

Añadir botones a un formulario en PowerShell de forma automática

PowerShell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$buttons_functionslist=@(
"Botón1",
"Botón2",
"Botón3"
"Botón4"
"Botón5"
)
 
$buttons_functionbuttoncount = $buttons_functionslist.count
 
$loop = 0
 
#Formulario
$Form = New-Object System.Windows.Forms.Form
$Form.Text="Formulario"
$Form.Size=New-Object System.Drawing.Size(500,500)
$Form.StartPosition="CenterScreen"
 
while($loop -lt $buttons_functionbuttoncount)
{
$thisbutton = New-Object System.Windows.Forms.Button
[string]$thisbuttonname = $buttons_functionslist[$loop]
$thisbutton.Text = $thisbuttonname
$thisbutton.size = New-Object System.Drawing.Size(100,20)
$thisbutton.Location = New-Object System.Drawing.Size(200,(20*$loop+1))
$thisbutton.Add_Click({
        Write-Host $this.Text
})
$Form.Controls.Add($thisbutton)
$loop += 1
}
 
$Form.ShowDialog()

Publicado el día 7 de junio de 2019

CATEGORÍAS

PowerShell

ETIQUETAS

Drawing, Jesús Niño, Jesús Niño Camazón, New-Object, showdialog, size, System.Drawing, System.Windows.Forms.Form, Windows, Windows.Forms.Form, Write-Host

MÁS

  • Dotar de funcionalidad a un formulario simple creado con XAML desde PowerShell
  • Escribir y un mensaje en una caja de texto y hacer click en un botón de un formulario de PowerShell de forma automática utilizando SendMessage y FindWindowEx de user32.dll
  • Ejercicios de PowerShell: realizar operaciones en un equipo remoto
  • Crear formulario dentro de otro formulario mediante una función con PowerShell
  • 11. Gestión del Directorio Activo (nivel intermedio)
  • Crear un formulario en PowerShell