Create polished demo videos without editing skills. Mac/Windows/Linux
fix(recording): align auto-zoom cursor data for windows capture
webadderall76025313a64b
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.tsindex fcb6e8d2..92245112 100644--- a/electron/ipc/handlers.ts+++ b/electron/ipc/handlers.ts@@ -1741,6 +1741,65 @@ async function resolveLinuxWindowBounds(source: SelectedSource): Promise<WindowB}}+async function resolveWindowsWindowBounds(source: SelectedSource): Promise<WindowBounds | null> {+ const windowId = parseWindowId(source?.id)+ const windowTitle = typeof source.windowTitle === 'string' ? source.windowTitle.trim() : source.name.trim()++ if (!windowId && !windowTitle) {+ return null+ }++ const script = [+ 'param([string]$windowId, [string]$windowTitle)',+ 'Add-Type -TypeDefinition @"',+ 'using System;',+ 'using System.Runtime.InteropServices;',+ 'public static class RecordlyWindowBounds {',+ ' [StructLayout(LayoutKind.Sequential)]',+ ' public struct RECT {',+ ' public int Left;',+ ' public int Top;',+ ' public int Right;',+ ' public int Bottom;',+ ' }',+ ' [DllImport("user32.dll")]',+ ' [return: MarshalAs(UnmanagedType.Bool)]',+ ' public static extern bool GetWindowRect(IntPtr hWnd, out RECT rect);',+ '}',+ '"@',+ '$handle = [Int64]0',+ 'if ($windowId) {',+ ' $handle = [Int64]$windowId',+ '}',+ 'if ($handle -le 0 -and $windowTitle) {',+ ' $matchingProcess = Get-Process | Where-Object { $_.MainWindowTitle -eq $windowTitle -or $_.MainWindowTitle -like "*$windowTitle*" } | Select-Object -First 1',+ ' if ($matchingProcess) {',+ ' $handle = $matchingProcess.MainWindowHandle.ToInt64()',+ ' }',+ '}',+ 'if ($handle -le 0) {',+ ' exit 1',+ '}',+ '$rect = New-Object RecordlyWindowBounds+RECT',+ 'if (-not [RecordlyWindowBounds]::GetWindowRect([IntPtr]$handle, [ref]$rect)) {',+ ' exit 1',+ '}',+ '@{ x = $rect.Left; y = $rect.Top; width = $rect.Right - $rect.Left; height = $rect.Bottom - $rect.Top } | ConvertTo-Json -Compress',+ ].join('\n')++ try {+ const { stdout } = await execFileAsync(+ 'powershell.exe',+ ['-NoProfile', '-Command', script, String(windowId ?? ''), windowTitle],+ { timeout: 1500 },+ )+ const bounds = JSON.parse(stdout) as WindowBounds+ return bounds && bounds.width > 0 && bounds.height > 0 ? bounds : null+ } catch {+ return null+ }+}+async function buildFfmpegCaptureArgs(source: SelectedSource, outputPath: string) {const commonOutputArgs = ['-an', '-c:v', 'libx264', '-preset', 'veryfast', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', outputPath]@@ -2609,6 +2668,8 @@ async function refreshSelectedWindowBounds() {if (process.platform === 'darwin') {bounds = await resolveMacWindowBounds(selectedSource)+ } else if (process.platform === 'win32') {+ bounds = await resolveWindowsWindowBounds(selectedSource)} else if (process.platform === 'linux') {bounds = await resolveLinuxWindowBounds(selectedSource)}@@ -2619,7 +2680,7 @@ async function refreshSelectedWindowBounds() {function startWindowBoundsCapture() {stopWindowBoundsCapture()- if (!['darwin', 'linux'].includes(process.platform) || !selectedSource?.id?.startsWith('window:')) {+ if (!['darwin', 'win32', 'linux'].includes(process.platform) || !selectedSource?.id?.startsWith('window:')) {return}@@ -3176,6 +3237,8 @@ export function registerIpcHandlers(} else if (isWindow) {if (process.platform === 'darwin') {bounds = await resolveMacWindowBounds(source)+ } else if (process.platform === 'win32') {+ bounds = await resolveWindowsWindowBounds(source)} else if (process.platform === 'linux') {bounds = await resolveLinuxWindowBounds(source)}