|
| 1 | +# Take a screenshot of the DVR-Scan UI and upload it as an artifact. |
| 2 | +name: Screenshot UI |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +env: |
| 8 | + ffmpeg_version: "7.1" |
| 9 | + |
| 10 | +jobs: |
| 11 | + run-ui-and-screenshot: |
| 12 | + runs-on: windows-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + python-version: ["3.12"] |
| 16 | + resolution: |
| 17 | + - {width: 1920, height: 1080, scale: 100} |
| 18 | + - {width: 2560, height: 1440, scale: 150} |
| 19 | + - {width: 3840, height: 2160, scale: 200} |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python ${{ matrix.python-version }} |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: ${{ matrix.python-version }} |
| 28 | + cache: 'pip' |
| 29 | + |
| 30 | + - name: Install uv and set the python version |
| 31 | + uses: astral-sh/setup-uv@v4 |
| 32 | + with: |
| 33 | + version: "0.5.11" |
| 34 | + python-version: ${{ matrix.python-version }} |
| 35 | + |
| 36 | + - name: Install Dependencies |
| 37 | + run: | |
| 38 | + uv pip install --upgrade pip build wheel virtualenv setuptools |
| 39 | + uv pip install -r requirements.txt |
| 40 | +
|
| 41 | + - name: Download FFMPEG |
| 42 | + |
| 43 | + with: |
| 44 | + repo: 'GyanD/codexffmpeg' |
| 45 | + version: 'tags/${{ env.ffmpeg_version }}' |
| 46 | + file: 'ffmpeg-${{ env.ffmpeg_version }}-full_build.7z' |
| 47 | + |
| 48 | + - name: Extract FFMPEG |
| 49 | + run: | |
| 50 | + 7z e ffmpeg-${{ env.ffmpeg_version }}-full_build.7z ffmpeg.exe -r |
| 51 | +
|
| 52 | + - name: Set screen resolution to ${{ matrix.resolution.width }}x${{ matrix.resolution.height }} |
| 53 | + |
| 54 | + with: |
| 55 | + width: ${{ matrix.resolution.width }} |
| 56 | + height: ${{ matrix.resolution.height }} |
| 57 | + |
| 58 | + - name: Set display scaling to ${{ matrix.resolution.scale }}% |
| 59 | + run: | |
| 60 | + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "LogPixels" -Value ([int]($env:SCALE * 96 / 100)) |
| 61 | + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "Win8DpiScaling" -Value 1 |
| 62 | + Rundll32.exe user32.dll, UpdatePerUserSystemParameters |
| 63 | + env: |
| 64 | + SCALE: ${{ matrix.resolution.scale }} |
| 65 | + shell: powershell |
| 66 | + |
| 67 | + - name: Run DVR-Scan |
| 68 | + run: | |
| 69 | + python -m dvr_scan.app & |
| 70 | +
|
| 71 | + - name: Take Screenshot |
| 72 | + run: | |
| 73 | + Add-Type -AssemblyName System.Windows.Forms |
| 74 | + Start-Sleep -Seconds 10 |
| 75 | + $bounds = [System.Windows.Forms.SystemInformation]::VirtualScreen |
| 76 | + $bitmap = New-Object System.Drawing.Bitmap $bounds.Width, $bounds.Height |
| 77 | + $graphics = [System.Drawing.Graphics]::FromImage($bitmap) |
| 78 | + $graphics.CopyFromScreen($bounds.Location, [System.Drawing.Point]::Empty, $bounds.Size) |
| 79 | + $bitmap.Save("dvr-scan-screenshot-${{ matrix.resolution.scale }}.png", [System.Drawing.Imaging.ImageFormat]::Png) |
| 80 | + $graphics.Dispose() |
| 81 | + $bitmap.Dispose() |
| 82 | + shell: powershell |
| 83 | + |
| 84 | + - name: Upload Screenshot |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: dvr-scan-screenshot-${{ matrix.resolution.scale }} |
| 88 | + path: dvr-scan-screenshot-${{ matrix.resolution.scale }}.png |
0 commit comments