param([string]$Title, [string]$ReadyFile, [switch]$Cover, [int]$Width=500, [int]$Height=300) Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $form = New-Object System.Windows.Forms.Form $form.Text = $Title $form.Size = New-Object System.Drawing.Size($Width, $Height) $form.StartPosition = 'Manual' $form.Location = New-Object System.Drawing.Point(100, 100) $form.TopMost = $true $form.BackColor = if ($Cover) { [System.Drawing.Color]::Magenta } else { [System.Drawing.Color]::Lime } $label = New-Object System.Windows.Forms.Label $label.Text = if ($Cover) { 'OCCLUDER - NOT TEST EVIDENCE' } else { 'ARTEMIS window capture fixture' } $label.Location = New-Object System.Drawing.Point(20, 25) $label.AutoSize = $true $form.Controls.Add($label) $button = New-Object System.Windows.Forms.Button $button.Text = 'Capture coordinate target' $button.AccessibleName = 'Capture coordinate target' $button.Location = New-Object System.Drawing.Point(100, 100) $button.Size = New-Object System.Drawing.Size(180, 50) $button.BackColor = [System.Drawing.Color]::Red $button.Add_Click({ [System.IO.File]::WriteAllText(($ReadyFile + '.clicked'), 'clicked') }) $form.Controls.Add($button) $timer = New-Object System.Windows.Forms.Timer $timer.Interval = 120000 $timer.Add_Tick({ $form.Close() }) $form.Add_Shown({ [System.IO.File]::WriteAllText($ReadyFile, $PID.ToString()) $timer.Start() }) try { [System.Windows.Forms.Application]::Run($form) } finally { $timer.Dispose(); $form.Dispose() }