JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

dvd | JustPaste.app
29 days ago9 views
👨‍💻Programming

dvd

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$form = New-Object System.Windows.Forms.Form
$form.Text = "DVD TXT"
$form.Width = 500
$form.Height = 350
$form.StartPosition = "Manual"
$form.Left = 100
$form.Top = 150
$form.TopMost = $true
$form.BackColor = "Black"

# Text box
$textbox = New-Object System.Windows.Forms.TextBox
$textbox.Multiline = $true
$textbox.Dock = "Fill"
$textbox.BackColor = "Black"
$textbox.ForeColor = "White"
$textbox.Font = New-Object System.Drawing.Font("Consolas",16)
$textbox.BorderStyle = "None"

$file = Join-Path $PSScriptRoot "text.txt"

if (Test-Path $file) {
    $textbox.Text = Get-Content $file -Raw
} else {
    $textbox.Text = "TYPE HERE!"
}

$form.Controls.Add($textbox)

# Movement state stored on the form
$form.Tag = @{
    DX = 5
    DY = 4
}

# Timer
$timer = New-Object System.Windows.Forms.Timer
$timer.Interval = 15

$timer.Add_Tick({

    $state = $form.Tag
    $screen = [System.Windows.Forms.Screen]::PrimaryScreen.WorkingArea

    $newX = $form.Left + $state.DX
    $newY = $form.Top + $state.DY

    # LEFT
    if ($newX -le $screen.Left) {
        $newX = $screen.Left
        $state.DX = [Math]::Abs($state.DX)
    }

    # RIGHT
    if ($newX + $form.Width -ge $screen.Right) {
        $newX = $screen.Right - $form.Width
        $state.DX = -[Math]::Abs($state.DX)
    }

    # TOP
    if ($newY -le $screen.Top) {
        $newY = $screen.Top
        $state.DY = [Math]::Abs($state.DY)
    }

    # BOTTOM
    if ($newY + $form.Height -ge $screen.Bottom) {
        $newY = $screen.Bottom - $form.Height
        $state.DY = -[Math]::Abs($state.DY)
    }

    $form.Left = [int]$newX
    $form.Top = [int]$newY
})

$form.Add_FormClosing({
    $textbox.Text | Set-Content $file
})

$timer.Start()

[void]$form.ShowDialog()
← Back to timeline