Add Remote Desktop screen selector + new-tab button (v2.2.0)
- CaptureModeRunner: screen index param (0=all, 1-N=specific monitor) - RtcService: reads screen from rdp_start JSON, passes to capture helper - Program.cs: parses optional screen index arg for --rdp-capture - RemoteDesktopPanel: screen dropdown (Alle/1-4), new-tab button - RdpPage: fullscreen standalone page at /rdp/:agentId - AgentDetailPage: removed dead _RemoteDesktopOld_unused code Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ public static class CaptureModeRunner
|
||||
private static readonly ImageCodecInfo JpegCodec =
|
||||
ImageCodecInfo.GetImageEncoders().First(c => c.FormatID == ImageFormat.Jpeg.Guid);
|
||||
|
||||
public static void Run(string portStr)
|
||||
public static void Run(string portStr, int screenIdx = 0)
|
||||
{
|
||||
if (!int.TryParse(portStr, out var port) || port <= 0) return;
|
||||
|
||||
@@ -24,22 +24,29 @@ public static class CaptureModeRunner
|
||||
var encParams = new EncoderParameters(1);
|
||||
encParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 60L);
|
||||
|
||||
// Alle Screens zusammenführen (Multi-Monitor-Support)
|
||||
// Capture-Region bestimmen: 0 = alle Screens, 1-N = spezifischer Screen
|
||||
var allScreens = System.Windows.Forms.Screen.AllScreens;
|
||||
int left = allScreens.Min(s => s.Bounds.X);
|
||||
int top = allScreens.Min(s => s.Bounds.Y);
|
||||
int right = allScreens.Max(s => s.Bounds.X + s.Bounds.Width);
|
||||
int bottom = allScreens.Max(s => s.Bounds.Y + s.Bounds.Height);
|
||||
int totalW = right - left;
|
||||
int totalH = bottom - top;
|
||||
Rectangle captureRect;
|
||||
if (screenIdx <= 0 || screenIdx > allScreens.Length)
|
||||
{
|
||||
int left = allScreens.Min(s => s.Bounds.X);
|
||||
int top = allScreens.Min(s => s.Bounds.Y);
|
||||
int right = allScreens.Max(s => s.Bounds.X + s.Bounds.Width);
|
||||
int bottom = allScreens.Max(s => s.Bounds.Y + s.Bounds.Height);
|
||||
captureRect = new Rectangle(left, top, right - left, bottom - top);
|
||||
}
|
||||
else
|
||||
{
|
||||
captureRect = allScreens[screenIdx - 1].Bounds;
|
||||
}
|
||||
|
||||
while (tcp.Connected)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bmp = new Bitmap(totalW, totalH, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
using var bmp = new Bitmap(captureRect.Width, captureRect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
using (var g = Graphics.FromImage(bmp))
|
||||
g.CopyFromScreen(left, top, 0, 0, new Size(totalW, totalH));
|
||||
g.CopyFromScreen(captureRect.X, captureRect.Y, 0, 0, new Size(captureRect.Width, captureRect.Height));
|
||||
|
||||
byte[] jpeg;
|
||||
using (var ms = new MemoryStream())
|
||||
|
||||
@@ -20,7 +20,9 @@ internal class Program
|
||||
return;
|
||||
|
||||
case "--rdp-capture":
|
||||
CaptureModeRunner.Run(args.Length > 1 ? args[1] : "");
|
||||
CaptureModeRunner.Run(
|
||||
args.Length > 1 ? args[1] : "",
|
||||
args.Length > 2 && int.TryParse(args[2], out var si) ? si : 0);
|
||||
return;
|
||||
|
||||
case "--dashboard":
|
||||
|
||||
@@ -65,9 +65,10 @@ public class RtcService
|
||||
|
||||
if (type == "rdp_start" && captureCts == null)
|
||||
{
|
||||
var screenIdx = obj["screen"]?.ToObject<int>() ?? 0;
|
||||
captureCts = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||
_ = CapturePipeLoopAsync(ws, captureCts.Token);
|
||||
AgentWorker.Log("RDP: Screen-Capture gestartet");
|
||||
_ = CapturePipeLoopAsync(ws, screenIdx, captureCts.Token);
|
||||
AgentWorker.Log($"RDP: Screen-Capture gestartet (screen={screenIdx})");
|
||||
}
|
||||
else if (type == "rdp_stop" && captureCts != null)
|
||||
{
|
||||
@@ -81,7 +82,7 @@ public class RtcService
|
||||
AgentWorker.Log("RDP: Getrennt");
|
||||
}
|
||||
|
||||
private async Task CapturePipeLoopAsync(ClientWebSocket ws, CancellationToken ct)
|
||||
private async Task CapturePipeLoopAsync(ClientWebSocket ws, int screenIdx, CancellationToken ct)
|
||||
{
|
||||
var exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule!.FileName;
|
||||
|
||||
@@ -90,7 +91,7 @@ public class RtcService
|
||||
listener.Start();
|
||||
var port = ((IPEndPoint)listener.LocalEndpoint).Port;
|
||||
|
||||
if (!SpawnCaptureHelper(exePath, port.ToString()))
|
||||
if (!SpawnCaptureHelper(exePath, port.ToString(), screenIdx))
|
||||
{
|
||||
listener.Stop();
|
||||
AgentWorker.Log("RDP: Helper-Start fehlgeschlagen");
|
||||
@@ -160,7 +161,7 @@ public class RtcService
|
||||
AgentWorker.Log("RDP: Frame-Loop beendet");
|
||||
}
|
||||
|
||||
private static bool SpawnCaptureHelper(string exePath, string portStr)
|
||||
private static bool SpawnCaptureHelper(string exePath, string portStr, int screenIdx = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -181,7 +182,7 @@ public class RtcService
|
||||
? "/ru \"INTERACTIVE\""
|
||||
: $"/ru \"{fullUser}\"";
|
||||
|
||||
var args = $"/create /tn \"{taskName}\" /tr \"\\\"{exePath}\\\" --rdp-capture {portStr}\" " +
|
||||
var args = $"/create /tn \"{taskName}\" /tr \"\\\"{exePath}\\\" --rdp-capture {portStr} {screenIdx}\" " +
|
||||
$"/sc ONCE /st {triggerTime} {ruArg} /it /f";
|
||||
|
||||
var p = Process.Start(new ProcessStartInfo("schtasks.exe", args)
|
||||
|
||||
Reference in New Issue
Block a user