@@ -132,47 +132,49 @@ jobs:
132132 if : cancelled() || failure()
133133 shell : bash # `pwsh` opens a Terminal window; `bash` does not!
134134 run : |
135- powershell -command 'Add-Type -TypeDefinition @"
136- using System;
137- using System.Runtime.InteropServices;
135+ powershell -command '
136+ Add-Type -TypeDefinition @"
137+ using System;
138+ using System.Runtime.InteropServices;
138139
139- public class DpiHelper {
140- [DllImport("user32.dll")]
141- public static extern bool SetProcessDpiAwarenessContext(IntPtr dpiContext);
140+ public class DpiHelper {
141+ [DllImport("user32.dll")]
142+ public static extern bool SetProcessDpiAwarenessContext(IntPtr dpiContext);
142143
143- [DllImport("Shcore.dll")]
144- public static extern int GetDpiForMonitor(IntPtr hmonitor, int dpiType, out uint dpiX, out uint dpiY);
144+ [DllImport("Shcore.dll")]
145+ public static extern int GetDpiForMonitor(IntPtr hmonitor, int dpiType, out uint dpiX, out uint dpiY);
145146
146- [DllImport("User32.dll")]
147- public static extern IntPtr MonitorFromPoint(System.Drawing.Point pt, uint dwFlags);
147+ [DllImport("User32.dll")]
148+ public static extern IntPtr MonitorFromPoint(System.Drawing.Point pt, uint dwFlags);
148149
149- public static uint GetDPI() {
150- // DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = -4
151- SetProcessDpiAwarenessContext((IntPtr)(-4));
150+ public static uint GetDPI() {
151+ // DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = -4
152+ SetProcessDpiAwarenessContext((IntPtr)(-4));
152153
153- uint dpiX, dpiY;
154- IntPtr monitor = MonitorFromPoint(new System.Drawing.Point(0, 0), 2); // MONITOR_DEFAULTTONEAREST
155- GetDpiForMonitor(monitor, 0, out dpiX, out dpiY); // MDT_EFFECTIVE_DPI
156- return (dpiX + dpiY) / 2;
157- }
158- }
159- "@ -ReferencedAssemblies "System.Drawing.dll"
154+ uint dpiX, dpiY;
155+ IntPtr monitor = MonitorFromPoint(new System.Drawing.Point(0, 0), 2); // MONITOR_DEFAULTTONEAREST
156+ GetDpiForMonitor(monitor, 0, out dpiX, out dpiY); // MDT_EFFECTIVE_DPI
157+ return (dpiX + dpiY) / 2;
158+ }
159+ }
160+ "@ -ReferencedAssemblies "System.Drawing.dll"
160161
161- $dpi = [DpiHelper]::GetDPI()
162+ $dpi = [DpiHelper]::GetDPI()
162163
163- [Reflection.Assembly]::LoadWithPartialName("System.Drawing")
164- function screenshot([Drawing.Rectangle]$bounds, $path) {
165- $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
166- $graphics = [Drawing.Graphics]::FromImage($bmp)
167- $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
168- $bmp.Save($path)
169- $graphics.Dispose()
170- $bmp.Dispose()
171- }
172- Add-Type -AssemblyName System.Windows.Forms
173- $screen = [System.Windows.Forms.Screen]::PrimaryScreen
174- $bounds = [Drawing.Rectangle]::FromLTRB(0, 0, $screen.Bounds.Width * $dpi / 96, $screen.Bounds.Height * $dpi / 96)
175- screenshot $bounds "screenshot.png"'
164+ [Reflection.Assembly]::LoadWithPartialName("System.Drawing")
165+ function screenshot([Drawing.Rectangle]$bounds, $path) {
166+ $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
167+ $graphics = [Drawing.Graphics]::FromImage($bmp)
168+ $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
169+ $bmp.Save($path)
170+ $graphics.Dispose()
171+ $bmp.Dispose()
172+ }
173+ Add-Type -AssemblyName System.Windows.Forms
174+ $screen = [System.Windows.Forms.Screen]::PrimaryScreen
175+ $bounds = [Drawing.Rectangle]::FromLTRB(0, 0, $screen.Bounds.Width * $dpi / 96, $screen.Bounds.Height * $dpi / 96)
176+ screenshot $bounds "screenshot.png"
177+ '
176178 - name : Upload screenshot, if taken
177179 uses : actions/upload-artifact@v4
178180 if : always() && steps.take-screenshot.conclusion == 'success'
0 commit comments