Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
wip(ui-mig): G3.2 极简页药丸改独立顶层窗、cineIn 挖区、优雅退出
Veyra Goal Agent536e7fef434a
diff --git a/apps/veyra-qml/main.cpp b/apps/veyra-qml/main.cppindex 71864dc9..c8539f71 100644--- a/apps/veyra-qml/main.cpp+++ b/apps/veyra-qml/main.cpp@@ -97,6 +97,34 @@ void syncVideoGeometry(QQuickWindow* window, QQuickItem* host) {struct Cover { QRectF rect; qreal radius = 0; };+// cineIn (pages.css @keyframes cineIn, plan M21): the stage is clipped with+// inset(12% 0 12% 0) and expands to inset(0). The picture is a native window, so+// the equivalent is its REGION: bands are cut off the top and bottom while the+// animation runs. The window and the swapchain keep their size, so this costs no+// ResizeBuffers - only the visible band changes. MinimalPage.inset carries the+// fraction (0.12 -> 0).+//+// The walk starts at the window's content item, NOT at the video host: the host is a+// sibling of the pages, so searching under it finds nothing. (The cover walk has the+// same shape and the same reason; both are rooted at the scene.)+qreal videoInsetFraction(QQuickItem* item) {+ if (!item) return 0.0;+ if (item->objectName() == QLatin1String("videoInset"))+ return item->property("frac").toReal();+ for (QQuickItem* child : item->childItems()) {+ const qreal f = videoInsetFraction(child);+ if (f > 0.0) return f;+ }+ return 0.0;+}++qreal sceneInsetFraction(QQuickWindow* window) {+ if (!window) return 0.0;+ QQuickItem* content = window->contentItem();+ QQuickItem* root = content && content->parentItem() ? content->parentItem() : content;+ return videoInsetFraction(root);+}+void collectCovers(QQuickItem* item, QList<Cover>& out) {if (!item->isVisible() || item->opacity() <= 0.0) return;if (item->objectName() == QLatin1String("videoCover")) {@@ -113,14 +141,16 @@ void collectCovers(QQuickItem* item, QList<Cover>& out) {// "videoCover" (popover panels, the dialog scrim) are cut out of the window's// region instead, so the QML under them shows. Scene rects include transforms,// so the hole follows a popover's scale-in. The region only changes when a cover-// moves; with none the window gets its full rectangle back.-void syncVideoCovers(QQuickWindow* window, QQuickItem* host) {+// moves or the cineIn inset changes; with neither the window gets its rectangle back.+void syncVideoCovers(QQuickWindow* window, QQuickItem* host, qreal inset) {if (!window || !host || !g_video) return;QList<Cover> covers;collectCovers(window->contentItem()->parentItem() ? window->contentItem()->parentItem(): window->contentItem(), covers);const qreal dpr = window->devicePixelRatio();const QPointF origin = host->mapToScene(QPointF(0, 0));+ const int w = std::max(1, int(std::floor(host->width() * dpr)));+ const int h = std::max(1, int(std::floor(host->height() * dpr)));static QList<QRect> last;QList<QRect> holes; // x, y, w, h; the radius rides along as a fifth rectfor (const Cover& c : covers) {@@ -129,11 +159,31 @@ void syncVideoCovers(QQuickWindow* window, QQuickItem* host) {int(std::ceil(local.width() * dpr)) + 1, int(std::ceil(local.height() * dpr)) + 1);holes << QRect(0, 0, int(std::round(c.radius * dpr * 2)), 0);}- if (holes == last) return;- last = holes;+ // cineIn rides along as a marker entry so one cache covers both, and the last+ // entry keeps its steadiness on a scene that renders without moving either.+ const int insetBand = int(std::round(inset * h));+ {+ QList<QRect> key = holes;+ key << QRect(0, 0, insetBand, 0);+ if (key == last) return;+ last = key;+ }+ // Covers win: a popover over the picture shows the QML beneath it, and the+ // clip inset only ever runs without one. A cover opening mid-animation simply+ // takes the whole rectangle back for as long as it is up.+ if (holes.isEmpty() && insetBand > 0) {+ // The design's inset(12% 0 12% 0 round 8px): both bands off the top and+ // bottom, corners eased with the band so the last frame has no snap.+ const int radius = std::max(2, int(std::round(8 * dpr * (inset / 0.12))));+ HRGN band = CreateRoundRectRgn(0, insetBand, w + 1, h - insetBand + 1, radius, radius);+ SetWindowRgn(g_video, band, TRUE);+ // The picture is a native window PrintWindow cannot show, so the cineIn+ // animation is evidenced here rather than in a screenshot.+ veyra::log::info("qml", std::format("cineIn inset band={}px of {} (frac={:.3f}) radius={}",+ insetBand, h, inset, radius));+ return;+ }if (holes.isEmpty()) { SetWindowRgn(g_video, nullptr, TRUE); return; }- const int w = std::max(1, int(std::floor(host->width() * dpr)));- const int h = std::max(1, int(std::floor(host->height() * dpr)));HRGN region = CreateRectRgn(0, 0, w, h);for (qsizetype i = 0; i + 1 < holes.size(); i += 2) {const QRect& hole = holes[i];@@ -228,10 +278,14 @@ int main(int argc, char** argv) {// --full-debug log every pointer movement the fullscreen controls see// --data-dir <path> presets and session history from that folder (read before the bridge exists)// --motion-probe <name> dock | page | switch | seg | menu: start that motion, log its value per frame+ // --exit-after <ms> quit the app by itself after N ms, so a test run ends+ // through the engine's own teardown instead of a killconst QStringList args = QCoreApplication::arguments();QString openPath;QVariantMap testOptions;QSize testSize;+ // --exit-after: see the switch table. 0 means "run until closed".+ int exitAfterMs = 0;for (int i = 1; i < args.size(); ++i) {const QString& a = args.at(i);const bool hasValue = i + 1 < args.size();@@ -263,6 +317,8 @@ int main(int argc, char** argv) {if (wh.size() == 2) testSize = QSize(wh.at(0).toInt(), wh.at(1).toInt());} else if (a == QLatin1String("--motion-probe") && hasValue) {testOptions.insert(QStringLiteral("motionProbe"), args.at(++i));+ } else if (a == QLatin1String("--exit-after") && hasValue) {+ exitAfterMs = args.at(++i).toInt();} else if (a == QLatin1String("--reduced-motion")) {testOptions.insert(QStringLiteral("reducedMotion"), true);} else if (a == QLatin1String("--slow-animations") && hasValue) {@@ -302,6 +358,32 @@ int main(int argc, char** argv) {}if (testSize.isValid()) window->resize(testSize);+ // Closing the window must run the engine's own teardown, not just end the loop.+ // A test harness that hard-kills the process (Stop-Process -Force) loses every+ // log line still in the file sink's 64 KB buffer - including the ones a test is+ // looking for, because the flush condition (250 ms since the last write) is+ // never reached when the process dies first. Qt's default for a window with no+ // explicit handler is to close it and exit on the last window, which does run+ // teardown; this makes it explicit so a harness can also ask for a clean exit+ // with --exit-after and get the same, complete log either way.+ QObject::connect(window, &QQuickWindow::closing, &app, [](QQuickCloseEvent*) {+ veyra::log::info("qml", "closing: quitting the application loop");+ // Flush before quitting: the file sink is a 64 KB _IOFBF buffer, so a run+ // that ends without this loses its last lines (the exact ones a headless+ // check is looking for). closeFile() at teardown would also flush, but a+ // quit path is not guaranteed to reach it.+ veyra::Logger::instance().flush();+ QCoreApplication::quit();+ }, Qt::DirectConnection);+ if (exitAfterMs > 0) {+ // Self-terminating test run: the same teardown path as a user closing the+ // window, so the log a harness reads is complete either way.+ QTimer::singleShot(exitAfterMs, &app, [window] {+ veyra::log::info("qml", "exit-after elapsed: closing the window");+ window->close();+ });+ }+// Reparent the native window under the QML window and keep it in step. The// host item is looked up by objectName so the QML side owns the layout and// this side only follows it.@@ -339,7 +421,7 @@ int main(int argc, char** argv) {w, h, int(host->x()), int(host->y())));}syncVideoGeometry(window, host);- syncVideoCovers(window, host);+ syncVideoCovers(window, host, sceneInsetFraction(window));};// V held shows the original picture on the professional page (AppShell: the// OriginalHold key, engine.comparison(1, false) until release). A Shortcut onlydiff --git a/qml/Veyra/CineBar.qml b/qml/Veyra/CineBar.qmlindex 45763780..544965ac 100644--- a/qml/Veyra/CineBar.qml+++ b/qml/Veyra/CineBar.qml@@ -105,7 +105,7 @@ Rectangle {TapHandler { id: cTap; onTapped: cbtn.tapped() }}- CBtn { glyph: "cc"; onTapped: {} }+ CBtn { glyph: "cc"; onTapped: ccMenu.openAt(this, "up") }CBtn { glyph: "back10"; onTapped: veyra.seekBy(-10) }// .play: 40px white circle with the play/pause glyph.@@ -130,7 +130,7 @@ Rectangle {}CBtn { glyph: "fwd10"; onTapped: veyra.seekBy(10) }- CBtn { glyph: "music"; onTapped: {} }+ CBtn { glyph: "music"; onTapped: audioMenu.openAt(this, "up") }}// .seekrow: mono times either side of the rail.@@ -144,8 +144,15 @@ Rectangle {font.pixelSize: 10}Item {+ id: seekAreaLayout.fillWidth: trueimplicitHeight: 14+ // .seek:hover .thumb { left: 44% } - the thumb tracks the real+ // progress, not the design's hard-coded 44%.+ readonly property real frac: Math.max(0, Math.min(1, veyra.progress))+ readonly property real hoverFrac: seekHover.hovered && width > 0+ ? Math.max(0, Math.min(1, seekHover.point.position.x / width))+ : fracRectangle {id: railanchors.verticalCenter: parent.verticalCenter@@ -155,12 +162,61 @@ Rectangle {color: Qt.rgba(1, 1, 1, 0.14)Behavior on height { NumberAnimation { duration: Theme.d(300); easing.bezierCurve: Theme.spring } }Rectangle {- width: parent.width * Math.max(0, Math.min(1, veyra.progress))+ width: parent.width * seekArea.fracheight: parent.heightradius: 9color: "#FFFFFF"}}+ // .seek .thumb: 11px dot, scale 0 -> 1 over .4s --spring on hover.+ Rectangle {+ width: 11; height: 11; radius: 5.5+ color: "#FFFFFF"+ x: seekArea.frac * seekArea.width - width / 2+ anchors.verticalCenter: parent.verticalCenter+ scale: seekHover.hovered ? 1 : 0+ Behavior on scale { NumberAnimation { duration: Theme.d(400); easing.bezierCurve: Theme.spring } }+ }+ // .seek .peek: 144x104 above the rail, opacity .15s, scale .85 -> 1+ // over .4s --spring from its bottom centre. The design shows a frame+ // of the target position; the engine keeps no frame the UI can read+ // (only save-to-file), so the scene area is the design's own black+ // plate and the time is real. Recorded as 尚未接入 in WORKLOG (B1).+ Rectangle {+ visible: opacity > 0.01+ width: 144+ height: 104+ radius: 8+ color: "#000000"+ border.width: 1+ border.color: Theme.stroke2+ x: Math.max(0, Math.min(parent.width - width,+ seekArea.hoverFrac * seekArea.width - width / 2))+ y: -height - 18+ opacity: seekHover.hovered ? 1 : 0+ scale: seekHover.hovered ? 1 : 0.85+ transformOrigin: Item.Bottom+ Behavior on opacity { NumberAnimation { duration: Theme.d(150) } }+ Behavior on scale { NumberAnimation { duration: Theme.d(400); easing.bezierCurve: Theme.spring } }+ Text {+ anchors.left: parent.left+ anchors.right: parent.right+ anchors.bottom: parent.bottom+ height: 23+ horizontalAlignment: Text.AlignHCenter+ verticalAlignment: Text.AlignVCenter+ text: veyra.formatTime(seekArea.hoverFrac * veyra.duration)+ color: Theme.t1+ font.family: Theme.fontMono+ font.pixelSize: 11+ font.weight: Font.Medium; font.variableAxes: Theme.axesMedium+ Rectangle {+ anchors.fill: parent+ z: -1+ color: "#111111"+ }+ }+ }HoverHandler { id: seekHover; cursorShape: Qt.PointingHandCursor }TapHandler {onTapped: point => {@@ -219,7 +275,9 @@ Rectangle {color: Theme.t2}HoverHandler { cursorShape: Qt.PointingHandCursor }- TapHandler { onTapped: root.requestPage("pro") }+ // The design's "全屏" button (title="全屏"). It used to call an+ // undefined root.requestPage("pro").+ TapHandler { onTapped: bar.requestFullscreen() }}}}@@ -239,4 +297,42 @@ Rectangle {else veyra.applyPresetIndex(o.preset)}}++ // 字幕 (design: app.menu(anchor, '字幕', [...])): the design lists embedded+ // tracks plus a settings dialog. The engine has no subtitle stream at all -+ // no track list, no renderer - so every entry here is the design's own text+ // with nothing behind it. Shown disabled rather than silently doing nothing.+ VMenu {+ id: ccMenu+ title: "字幕"+ items: [+ { label: "关闭", disabled: true },+ { label: "简体中文 · 内嵌 ASS", disabled: true },+ { label: "English · 内嵌 SRT", disabled: true },+ { label: "加载外部字幕…", icon: "import", disabled: true },+ { sep: true },+ { label: "字幕设置…", note: "字体、字号、描边、位置、延时(尚未接入)", icon: "type", disabled: true }+ ]+ onPicked: veyra.logUi("ui-cine", "subtitle menu picked index=" + i + " (no subtitle stream in the engine)")+ }++ // 音轨: this one is real - the bridge exposes the file's audio streams and the+ // selected index, so the list and the check mark both come from the engine.+ VMenu {+ id: audioMenu+ title: "音轨"+ // The bridge's label already carries language · title · codec; only the+ // channel count is separate.+ readonly property var mk: t => ({ label: t.label,+ note: t.channels > 0 ? (t.channels + " 声道") : "",+ checked: t.index === veyra.selectedAudioTrack })+ items: veyra.audioTracks.length > 0+ ? veyra.audioTracks.map(mk).concat([{ sep: true },+ { label: "音频设置…", note: "输出设备、音画同步、偏移", icon: "music", act: "dlg" }])+ : [{ label: "片源没有音轨或尚未打开", disabled: true }]+ onPicked: (i, o) => {+ if (o.act === "dlg") return bar.requestPage("set")+ if (o.index !== undefined) veyra.selectedAudioTrack = o.index+ }+ }}diff --git a/qml/Veyra/FullscreenBar.qml b/qml/Veyra/FullscreenBar.qmlindex bf61a915..09cb62f8 100644--- a/qml/Veyra/FullscreenBar.qml+++ b/qml/Veyra/FullscreenBar.qml@@ -26,6 +26,12 @@ Window {signal activity()readonly property bool hovered: bar.hoveredreadonly property bool menuOpen: bar.menuOpen+ // G3.2 (D1): the same window carries the cinema pill in windowed 极简 mode, where+ // it straddles the picture's bottom edge: its top is pillTop (owner-relative),+ // half over the native video window and half below it. In fullscreen it sits+ // 24px above the screen edge.+ property bool cinema: false+ property real pillTop: 0transientParent: ownerflags: Qt.Tool | Qt.FramelessWindowHint | Qt.WindowDoesNotAcceptFocus@@ -36,9 +42,11 @@ Window {readonly property int barWidth: Math.min(860, owner.width - 48)width: barWidthheight: 92 + menuRoom- // Centred, 24px above the screen's bottom edge (the design's 24px side margin).+ // Centred; fullscreen: 24px above the screen's bottom edge (the design's 24px+ // side margin); cinema: .cine-bar top = --pic-h - 46.x: owner.x + Math.round((owner.width - width) / 2)- y: owner.y + owner.height - height - 24+ y: cinema ? owner.y + Math.round(pillTop) - menuRoom+ : owner.y + owner.height - height - 24// Hidden outright rather than transparent, so it composes nothing over the video// (the PresentMon comparison in the plan measures exactly this). The fade is@@ -55,16 +63,37 @@ Window {onHitRectChanged: veyra.setWindowMask(win, hitRect)Component.onCompleted: veyra.setWindowMask(win, hitRect)+ // barIn (pages.css): from opacity 0, translate 30px, scale .94, .8s --spring+ // after .12s. Played by enter() when the cinema page shows.+ property real enterDy: 0+ property real enterScale: 1+ property real enterOpacity: 1+ function enter() { barIn.restart() }+ // The cinema pill enters with barIn each time it appears (page shown, dialog+ // closed); the fullscreen one keeps the plain fade and rise.+ onShownChanged: if (shown && cinema) enter()+ SequentialAnimation {+ id: barIn+ ScriptAction { script: { win.enterDy = 30; win.enterScale = 0.94; win.enterOpacity = 0 } }+ PauseAnimation { duration: Theme.d(120) }+ ParallelAnimation {+ NumberAnimation { target: win; property: "enterDy"; to: 0; duration: Theme.d(800); easing.bezierCurve: Theme.spring }+ NumberAnimation { target: win; property: "enterScale"; to: 1; duration: Theme.d(800); easing.bezierCurve: Theme.spring }+ NumberAnimation { target: win; property: "enterOpacity"; to: 1; duration: Theme.d(800); easing.bezierCurve: Theme.spring }+ }+ }+CineBar {id: barx: 0y: win.menuRoomwidth: win.widthheight: 92- fullscreen: true- opacity: win.fade+ fullscreen: !win.cinema+ opacity: win.fade * win.enterOpacity// barIn-like rise while showing: translate 30px -> 0 with the fade.- transform: Translate { y: (1 - win.fade) * 30 }+ transform: Translate { y: (win.cinema ? 0 : (1 - win.fade) * 30) + win.enterDy }+ scale: win.enterScaleonRequestPage: p => win.requestPage(p)onRequestFullscreen: win.requestFullscreen()onRequestLock: win.requestLock()diff --git a/qml/Veyra/Main.qml b/qml/Veyra/Main.qmlindex 58e3021c..bfbc8f4e 100644--- a/qml/Veyra/Main.qml+++ b/qml/Veyra/Main.qml@@ -39,10 +39,10 @@ Window {// Cinema geometry, straight from the prototype: the picture is width/aspect// and the window is that plus the lower half of the control pill.property real filmAspect: 2.39- // The design straddles the bar on the picture edge with barBelow = 46. The bar- // needs its own window for that, which does not exist yet, so the picture- // area reserves the whole bar height instead.- readonly property int barBelow: 92+ // The design straddles the bar on the picture edge: BAR_BELOW = 46. The pill is+ // its own top-level window (FullscreenBar, D1), so it can sit over the native+ // video window.+ readonly property int barBelow: 46readonly property real pictureHeight: Math.round(width / filmAspect)function fitToFilm(aspect) {@@ -298,7 +298,14 @@ Window {FullscreenBar {id: fullBarowner: root- shown: root.fullscreen && root.fullControls && !root.fullLocked && veyra.hasSource+ // Windowed cinema: the pill straddles the picture edge (D1). It hides under+ // an open dialog, which lives in the main window below it.+ cinema: root.cinema && !root.fullscreen+ pillTop: root.pictureHeight - 46+ shown: veyra.hasSource && (root.fullscreen ? root.fullControls && !root.fullLocked+ : root.cinema && root.shownPage === "min"+ && root.leavingPage === "" && dialogs.dialog === ""+ && root.visibility !== Window.Minimized)onRequestPage: p => { root.toggleFullscreen(); root.page = p }onRequestFullscreen: root.toggleFullscreen()onRequestLock: root.toggleLock()diff --git a/qml/Veyra/MinimalPage.qml b/qml/Veyra/MinimalPage.qmlindex dcee7ce7..b6161674 100644--- a/qml/Veyra/MinimalPage.qml+++ b/qml/Veyra/MinimalPage.qml@@ -15,12 +15,39 @@ VPage {id: rootsignal requestPage(string page)- // Where the picture ends and the pill straddles. Main.qml sets the window- // height to pictureHeight + 46, so the bar's top edge is pictureHeight - 46.- // The picture is the window minus the control bar's full height: the bar- // sits below the picture rather than straddling it, because a native video- // window always draws above the QML scene.- readonly property real pictureHeight: parent ? parent.height - 92 : 0+ // cineIn (pages.css @keyframes cineIn, plan M21 "上下各 12% 裁切展开 | 子窗口区域"):+ // the stage opens from inset(12% 0 12% 0 round 8px) to inset(0). The picture is a+ // native window above this scene, so a QML clip would not touch it - main.cpp+ // reads this item and insets the video window's REGION instead (no resize, so no+ // swapchain churn). It carries the value only: invisible, 0x0, never drawn. The+ // C++ walk does not filter on visibility (unlike the cover walk, which must), so+ // an invisible carrier still reaches it.+ Item {+ id: cineIn+ objectName: "videoInset"+ property real frac: 0+ visible: false+ width: 0+ height: 0+ }+ // The animation itself: 12% -> 0 over .8s --spring-soft, started when the page+ // shows through an animated switch (VPage.enter). A cold start (first open) has+ // nothing to animate from, so it goes straight to 0.+ NumberAnimation {+ id: cineInAnim+ target: cineIn+ property: "frac"+ to: 0+ duration: Theme.d(800)+ easing.bezierCurve: Theme.springSoft+ }+ onEnter: { cineIn.frac = 0.12; cineInAnim.restart() }++ // Where the picture ends: Main.qml sets the window height to the picture plus+ // BAR_BELOW (46), the lower half of the control pill. The pill itself is a+ // separate top-level window (FullscreenBar in cinema mode, D1), because the+ // native video window draws above this whole scene.+ readonly property real pictureHeight: parent ? parent.height - 46 : 0// --- the picture ------------------------------------------------------// .min .stage: full width, the picture height, radius 8 (the window radius),@@ -47,28 +74,6 @@ VPage {}}- // --- the control pill (CineBar.qml) ------------------------------------- // .cine-bar: min(860px, 100% - 48px), below the picture (see pictureHeight).- CineBar {- id: cineBar- anchors.horizontalCenter: parent.horizontalCenter- width: Math.min(860, root.width - 48)- height: 92- y: root.pictureHeight- visible: veyra.hasSource- onRequestPage: p => root.requestPage(p)- onRequestFullscreen: root.requestFullscreen()-- // barIn: opacity 0, translate 30px, scale .94 -> settled- opacity: 0- SequentialAnimation on opacity {- running: cineBar.visible- PauseAnimation { duration: Theme.d(120) }- NumberAnimation { to: 1.0; duration: Theme.d(800); easing.bezierCurve: Theme.spring }- }- }--// Report the film aspect upward so the window can snap to it.onPictureHeightChanged: if (veyra.sourceAspect > 0.2) root.requestAspect(veyra.sourceAspect)signal requestAspect(real aspect)diff --git a/qml/Veyra/Theme.qml b/qml/Veyra/Theme.qmlindex 6e7749fd..78d6b4e4 100644--- a/qml/Veyra/Theme.qml+++ b/qml/Veyra/Theme.qml@@ -103,6 +103,10 @@ QtObject {// axis directly (G1.3, tmp/.../min/Font.qml).readonly property string fontUi: "Noto Sans SC"readonly property var axesDemiBold: ({ "wght": 600 })+ // 500: the design's .seek .peek time strip is `font: 500 11px/1 var(--f-mono)`.+ // Same reason as DemiBold - 600 lands on a thin instance, so the axis is set+ // explicitly rather than left to font.weight.+ readonly property var axesMedium: ({ "wght": 500 })readonly property string fontMono: "Consolas"readonly property real fsEyebrow: 11readonly property real fsSmall: 11.5diff --git a/tools/qt_probe/hover-shot.ps1 b/tools/qt_probe/hover-shot.ps1index 2b2b7746..0774d889 100644--- a/tools/qt_probe/hover-shot.ps1+++ b/tools/qt_probe/hover-shot.ps1@@ -13,7 +13,10 @@ param(# modifiers held ("k17+76" is Ctrl+L), or "kd<vk>" / "ku<vk>" to press or release one key. One# string: powershell -File does not split an array argument.[string]$Steps = '640,4,top',- [int]$WaitSeconds = 8+ [int]$WaitSeconds = 8,+ # Also paint the process's other top-level windows (the cinema pill window, G3.2)+ # over the main one at their screen offsets. PrintWindow renders one HWND only.+ [switch]$Compose)Add-Type -AssemblyName System.DrawingAdd-Type @"@@ -29,8 +32,18 @@ public class HW {[DllImport("user32.dll")] public static extern void keybd_event(byte vk, byte scan, uint f, IntPtr e);[DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr h, IntPtr after, int x, int y, int cx, int cy, uint f);[DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr h);+ [DllImport("user32.dll")] public static extern int GetWindowRgnBox(IntPtr h, out RECT r);delegate bool EnumProc(IntPtr h, IntPtr p);[StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left, Top, Right, Bottom; }+ public static System.Collections.Generic.List<IntPtr> All(uint want) {+ var list = new System.Collections.Generic.List<IntPtr>();+ EnumWindows((h, p) => {+ uint pid; GetWindowThreadProcessId(h, out pid);+ if (pid == want && IsWindowVisible(h)) list.Add(h);+ return true;+ }, IntPtr.Zero);+ return list; // top of the z-order first+ }public static IntPtr Largest(uint want) {IntPtr best = IntPtr.Zero; long area = 0;EnumWindows((h, p) => {@@ -77,6 +90,27 @@ foreach ($s in ($Steps -split ';')) {$bmp = New-Object System.Drawing.Bitmap $w, $ht$g = [System.Drawing.Graphics]::FromImage($bmp)$dc = $g.GetHdc(); [HW]::PrintWindow($h, $dc, 2) | Out-Null; $g.ReleaseHdc($dc)+ if ($Compose) {+ $others = [HW]::All([uint32]$p.Id); $others.Reverse()+ foreach ($o in $others) {+ if ($o -eq $h) { continue }+ $orr = New-Object HW+RECT; [HW]::GetWindowRect($o, [ref]$orr) | Out-Null+ $ow = $orr.Right - $orr.Left; $oh = $orr.Bottom - $orr.Top+ if ($ow -le 0 -or $oh -le 0) { continue }+ $ob = New-Object System.Drawing.Bitmap $ow, $oh, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)+ $og = [System.Drawing.Graphics]::FromImage($ob); $og.Clear([System.Drawing.Color]::Transparent)+ $odc = $og.GetHdc(); [HW]::PrintWindow($o, $odc, 2) | Out-Null; $og.ReleaseHdc($odc); $og.Dispose()+ # A masked window (setMask -> SetWindowRgn) shows only its region on screen;+ # PrintWindow paints the rest black, so only the region's box is composed.+ $box = New-Object HW+RECT+ $kind = [HW]::GetWindowRgnBox($o, [ref]$box)+ if ($kind -le 1) { $box.Left = 0; $box.Top = 0; $box.Right = $ow; $box.Bottom = $oh }+ $src = New-Object System.Drawing.Rectangle $box.Left, $box.Top, ($box.Right - $box.Left), ($box.Bottom - $box.Top)+ $g.DrawImage($ob, ($orr.Left - $r.Left + $box.Left), ($orr.Top - $r.Top + $box.Top), $src, [System.Drawing.GraphicsUnit]::Pixel)+ $ob.Save((Join-Path $Out ("hover-$name-win-$($o.ToInt64()).png")), [System.Drawing.Imaging.ImageFormat]::Png); $ob.Dispose()+ " composed window $($o.ToInt64()) ${ow}x${oh} at $($orr.Left - $r.Left),$($orr.Top - $r.Top)"+ }+ }$file = Join-Path $Out ("hover-$name.png")$bmp.Save($file, [System.Drawing.Imaging.ImageFormat]::Png); $g.Dispose(); $bmp.Dispose()"saved $file (${w}x${ht})"