Files
Artemis-Plugins/tests/capture-fixture.ps1
T

32 lines
1.4 KiB
PowerShell

param([string]$Title, [string]$ReadyFile, [switch]$Cover)
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(500, 300)
$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() }