$extra=[Native41]::Top([uint32]$l.pid,'OpenHoops extra fields')
$observed=Get-Content "$o\ui-inspect.json" -Raw|ConvertFrom-Json
$bar=[Native41]::GetParent([Native41]::Button($extra,'Apply fields'))
$candidates=@($observed.controls|Where-Object{$_.class -match '^WindowsForms10.Window.8' -and $_.handle -ne $bar.ToInt64()})
if($candidates.Count -ne 1){throw 'Observed extra grid is ambiguous'}
$grid=[IntPtr][long]$candidates[0].handle
if(![Native41]::IsChild($extra,$grid)){throw 'Observed grid is not owned by the extra-fields window'}
$null=[Native41]::SetForegroundWindow($extra)
Start-Sleep -Milliseconds 200
if([Native41]::GetForegroundWindow() -ne $extra){throw 'Owned extra window is not foreground'}
$rect=New-Object Native41+Rect;$null=[Native41]::GetWindowRect($grid,[ref]$rect)
$null=[Native41]::SetCursorPos(($rect.L+600),($rect.T+36))
$point=New-Object Native41+Point;$point.X=$rect.L+600;$point.Y=$rect.T+36
$hit=[Native41]::WindowFromPoint($point);$owner=0;$null=[Native41]::GetWindowThreadProcessId($hit,[ref]$owner)
if($owner -ne $l.pid){throw 'Target point is not owned by the editor'}
[Native41]::mouse_event(2,0,0,0,[UIntPtr]::Zero);[Native41]::mouse_event(4,0,0,0,[UIntPtr]::Zero)
Start-Sleep -Milliseconds 150
[Native41]::keybd_event(113,0,0,[UIntPtr]::Zero);[Native41]::keybd_event(113,0,2,[UIntPtr]::Zero)
Start-Sleep -Milliseconds 300
$input=[Native41]::Class($grid,'EDIT')
$null=[Native41]::SendMessage($input,12,[IntPtr]::Zero,'Modern display name')
if([Native41]::Title($input) -ne 'Modern display name'){throw 'Native edit input readback differs'}
Click $extra 'Apply fields'
Start-Sleep -Milliseconds 900
Click $main 'Review changes';Start-Sleep -Seconds 2
$report=[Native41]::Top([uint32]$l.pid,'Changes since opening')
$summary=@([Native41]::Children($report)|ForEach-Object{[Native41]::Title($_)}|Where-Object{$_ -match 'changes.*added records'})
@{pid=$l.pid;utc=[DateTime]::UtcNow.ToString('o');editedField='org.openhoops.ui.display_name';editedValue='Modern display name';record=0;section=3;summary=$summary;sourceSha256=(Get-FileHash "$r\roster-editor41e\Studio.ROS").Hash;companionSha256=(Get-FileHash "$r\roster-editor41e\Studio.ROS.openhoops.json").Hash}|ConvertTo-Json -Depth 4|Set-Content "$o\ui-edit2.json"
