Skip to content

Instantly share code, notes, and snippets.

@terremoth
Created July 5, 2026 02:05
Show Gist options
  • Select an option

  • Save terremoth/3e2ba8bb013e0ed71013f3bfd6e0edeb to your computer and use it in GitHub Desktop.

Select an option

Save terremoth/3e2ba8bb013e0ed71013f3bfd6e0edeb to your computer and use it in GitHub Desktop.
Less than 1kb Notepad program
Add-Type -AssemblyName System.Windows.Forms
$f=[Windows.Forms.Form]::new();$f.Text="MicroPad";$f.Width=640;$f.Height=480
$t=[Windows.Forms.TextBox]::new();$t.Multiline=$true;$t.Dock="Fill";$t.ScrollBars="Both"
$m=[Windows.Forms.MenuStrip]::new()
$a=[Windows.Forms.ToolStripMenuItem]::new("Arquivo")
$n=[Windows.Forms.ToolStripMenuItem]::new("Novo")
$n.add_Click({$t.Text=""})
$o=[Windows.Forms.ToolStripMenuItem]::new("Abrir...")
$o.add_Click({$d=[Windows.Forms.OpenFileDialog]::new();if($d.ShowDialog() -eq "OK"){$t.Text=[IO.File]::ReadAllText($d.FileName)}})
$s=[Windows.Forms.ToolStripMenuItem]::new("Salvar...")
$s.add_Click({$d=[Windows.Forms.SaveFileDialog]::new();if($d.ShowDialog() -eq "OK"){[IO.File]::WriteAllText($d.FileName,$t.Text)}})
$e=[Windows.Forms.ToolStripMenuItem]::new("Sair")
$e.add_Click({$f.Close()})
$a.DropDownItems.AddRange(@($n,$o,$s,$e))
$m.Items.Add($a)
$f.Controls.AddRange(@($t,$m))
$f.MainMenuStrip=$m
[Windows.Forms.Application]::Run($f)
@terremoth

terremoth commented Jul 5, 2026 •

Copy link
Copy Markdown
Author

To execute:

powershell -ExecutionPolicy Bypass -File MicroPad.ps1

or once for all time, at the powershell:

Unblock-File -Path MicroPad.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment