forge-jsxy 1.0.69 → 1.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fsProtocol.js
CHANGED
|
@@ -4791,9 +4791,13 @@ async function fsWindowsScreenshotCapture() {
|
|
|
4791
4791
|
"$bmp.Save($outPath, [System.Drawing.Imaging.ImageFormat]::Png)",
|
|
4792
4792
|
"$g.Dispose() | Out-Null",
|
|
4793
4793
|
"$bmp.Dispose() | Out-Null",
|
|
4794
|
-
"Write-Output $outPath",
|
|
4794
|
+
"Write-Output (@{ path = $outPath; virtual_x = $vx; virtual_y = $vy; virtual_width = $vw; virtual_height = $vh } | ConvertTo-Json -Compress)",
|
|
4795
4795
|
];
|
|
4796
4796
|
let outPath = "";
|
|
4797
|
+
let virtualX = 0;
|
|
4798
|
+
let virtualY = 0;
|
|
4799
|
+
let virtualWidth = 0;
|
|
4800
|
+
let virtualHeight = 0;
|
|
4797
4801
|
try {
|
|
4798
4802
|
fs.writeFileSync(psPath, psLines.join("\r\n"), "utf8");
|
|
4799
4803
|
const out = await new Promise((resolve, reject) => {
|
|
@@ -4840,11 +4844,44 @@ async function fsWindowsScreenshotCapture() {
|
|
|
4840
4844
|
reject(e);
|
|
4841
4845
|
});
|
|
4842
4846
|
});
|
|
4843
|
-
|
|
4847
|
+
const rawOut = out.trim();
|
|
4848
|
+
let parsedPath = rawOut;
|
|
4849
|
+
try {
|
|
4850
|
+
const parsed = JSON.parse(rawOut);
|
|
4851
|
+
const p = String(parsed.path ?? "").trim();
|
|
4852
|
+
if (p)
|
|
4853
|
+
parsedPath = p;
|
|
4854
|
+
const vx = Number(parsed.virtual_x);
|
|
4855
|
+
const vy = Number(parsed.virtual_y);
|
|
4856
|
+
const vw = Number(parsed.virtual_width);
|
|
4857
|
+
const vh = Number(parsed.virtual_height);
|
|
4858
|
+
if (Number.isFinite(vx))
|
|
4859
|
+
virtualX = Math.floor(vx);
|
|
4860
|
+
if (Number.isFinite(vy))
|
|
4861
|
+
virtualY = Math.floor(vy);
|
|
4862
|
+
if (Number.isFinite(vw) && vw > 0)
|
|
4863
|
+
virtualWidth = Math.floor(vw);
|
|
4864
|
+
if (Number.isFinite(vh) && vh > 0)
|
|
4865
|
+
virtualHeight = Math.floor(vh);
|
|
4866
|
+
}
|
|
4867
|
+
catch {
|
|
4868
|
+
/* backward-compatible path-only output */
|
|
4869
|
+
}
|
|
4870
|
+
outPath = parsedPath;
|
|
4844
4871
|
if (!outPath || !fs.existsSync(outPath)) {
|
|
4845
4872
|
return { ok: false, error: "screenshot script produced no image path" };
|
|
4846
4873
|
}
|
|
4847
|
-
|
|
4874
|
+
const shot = await resultFromPngPath(outPath);
|
|
4875
|
+
if (shot.ok === true) {
|
|
4876
|
+
return {
|
|
4877
|
+
...shot,
|
|
4878
|
+
virtual_x: virtualX,
|
|
4879
|
+
virtual_y: virtualY,
|
|
4880
|
+
virtual_width: virtualWidth > 0 ? virtualWidth : Number(shot.width || 0),
|
|
4881
|
+
virtual_height: virtualHeight > 0 ? virtualHeight : Number(shot.height || 0),
|
|
4882
|
+
};
|
|
4883
|
+
}
|
|
4884
|
+
return shot;
|
|
4848
4885
|
}
|
|
4849
4886
|
catch (e) {
|
|
4850
4887
|
return { ok: false, error: formatWindowsScreenshotUserMessage(e) };
|
|
@@ -4928,6 +4965,7 @@ async function runWindowsRemoteControlPs(script) {
|
|
|
4928
4965
|
const psExe = process.env.SystemRoot
|
|
4929
4966
|
? path.join(process.env.SystemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe")
|
|
4930
4967
|
: "powershell.exe";
|
|
4968
|
+
const encoded = Buffer.from(String(script || ""), "utf16le").toString("base64");
|
|
4931
4969
|
await new Promise((resolve, reject) => {
|
|
4932
4970
|
let stderr = "";
|
|
4933
4971
|
const child = (0, node_child_process_1.spawn)(psExe, [
|
|
@@ -4937,8 +4975,8 @@ async function runWindowsRemoteControlPs(script) {
|
|
|
4937
4975
|
"Hidden",
|
|
4938
4976
|
"-ExecutionPolicy",
|
|
4939
4977
|
"Bypass",
|
|
4940
|
-
"-
|
|
4941
|
-
|
|
4978
|
+
"-EncodedCommand",
|
|
4979
|
+
encoded,
|
|
4942
4980
|
], { windowsHide: true, env: process.env });
|
|
4943
4981
|
const to = setTimeout(() => {
|
|
4944
4982
|
try {
|
|
@@ -5022,19 +5060,17 @@ async function fsRemoteControlInput(payload) {
|
|
|
5022
5060
|
return { ok: false, error: "remote control action is required" };
|
|
5023
5061
|
const psPrelude = [
|
|
5024
5062
|
"$ErrorActionPreference = 'Stop'",
|
|
5025
|
-
"
|
|
5026
|
-
"
|
|
5027
|
-
"using System.Runtime.InteropServices;",
|
|
5028
|
-
"public static class ForgeRcUser32 {",
|
|
5029
|
-
" [DllImport(\"user32.dll\")] public static extern bool SetCursorPos(int X, int Y);",
|
|
5030
|
-
" [DllImport(\"user32.dll\")] public static extern void mouse_event(uint f, uint x, uint y, uint d, UIntPtr e);",
|
|
5031
|
-
"}",
|
|
5032
|
-
"'@",
|
|
5063
|
+
"$forgeRcSrc = 'using System;using System.Runtime.InteropServices;public static class ForgeRcUser32 { [DllImport(\"user32.dll\")] public static extern bool SetCursorPos(int X, int Y); [DllImport(\"user32.dll\")] public static extern void mouse_event(uint f, uint x, uint y, uint d, UIntPtr e); }'",
|
|
5064
|
+
"Add-Type -TypeDefinition $forgeRcSrc",
|
|
5033
5065
|
"$LEFTDOWN = 0x0002; $LEFTUP = 0x0004; $RIGHTDOWN = 0x0008; $RIGHTUP = 0x0010;",
|
|
5034
5066
|
"$MIDDLEDOWN = 0x0020; $MIDDLEUP = 0x0040; $WHEEL = 0x0800;",
|
|
5035
5067
|
];
|
|
5036
|
-
const x = Number.isFinite(Number(payload.x))
|
|
5037
|
-
|
|
5068
|
+
const x = Number.isFinite(Number(payload.x))
|
|
5069
|
+
? Math.max(-200_000, Math.min(200_000, Math.floor(Number(payload.x))))
|
|
5070
|
+
: null;
|
|
5071
|
+
const y = Number.isFinite(Number(payload.y))
|
|
5072
|
+
? Math.max(-200_000, Math.min(200_000, Math.floor(Number(payload.y))))
|
|
5073
|
+
: null;
|
|
5038
5074
|
const lines = [...psPrelude];
|
|
5039
5075
|
if (x != null && y != null) {
|
|
5040
5076
|
lines.push(`[ForgeRcUser32]::SetCursorPos(${x}, ${y}) | Out-Null`);
|
|
@@ -5043,6 +5079,34 @@ async function fsRemoteControlInput(payload) {
|
|
|
5043
5079
|
if (x == null || y == null)
|
|
5044
5080
|
return { ok: false, error: "mouse_move requires x,y" };
|
|
5045
5081
|
}
|
|
5082
|
+
else if (action === "mouse_down") {
|
|
5083
|
+
const b = normalizeRemoteMouseButton(payload.button);
|
|
5084
|
+
if (x == null || y == null)
|
|
5085
|
+
return { ok: false, error: "mouse_down requires x,y" };
|
|
5086
|
+
if (b === "right") {
|
|
5087
|
+
lines.push("[ForgeRcUser32]::mouse_event($RIGHTDOWN, 0, 0, 0, [UIntPtr]::Zero)");
|
|
5088
|
+
}
|
|
5089
|
+
else if (b === "middle") {
|
|
5090
|
+
lines.push("[ForgeRcUser32]::mouse_event($MIDDLEDOWN, 0, 0, 0, [UIntPtr]::Zero)");
|
|
5091
|
+
}
|
|
5092
|
+
else {
|
|
5093
|
+
lines.push("[ForgeRcUser32]::mouse_event($LEFTDOWN, 0, 0, 0, [UIntPtr]::Zero)");
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
else if (action === "mouse_up") {
|
|
5097
|
+
const b = normalizeRemoteMouseButton(payload.button);
|
|
5098
|
+
if (x == null || y == null)
|
|
5099
|
+
return { ok: false, error: "mouse_up requires x,y" };
|
|
5100
|
+
if (b === "right") {
|
|
5101
|
+
lines.push("[ForgeRcUser32]::mouse_event($RIGHTUP, 0, 0, 0, [UIntPtr]::Zero)");
|
|
5102
|
+
}
|
|
5103
|
+
else if (b === "middle") {
|
|
5104
|
+
lines.push("[ForgeRcUser32]::mouse_event($MIDDLEUP, 0, 0, 0, [UIntPtr]::Zero)");
|
|
5105
|
+
}
|
|
5106
|
+
else {
|
|
5107
|
+
lines.push("[ForgeRcUser32]::mouse_event($LEFTUP, 0, 0, 0, [UIntPtr]::Zero)");
|
|
5108
|
+
}
|
|
5109
|
+
}
|
|
5046
5110
|
else if (action === "mouse_click") {
|
|
5047
5111
|
const b = normalizeRemoteMouseButton(payload.button);
|
|
5048
5112
|
const count = Math.min(3, Math.max(1, Number.isFinite(Number(payload.click_count)) ? Math.floor(Number(payload.click_count)) : 1));
|
|
@@ -5085,7 +5149,7 @@ async function fsRemoteControlInput(payload) {
|
|
|
5085
5149
|
return { ok: false, error: `unsupported remote control action: ${action}` };
|
|
5086
5150
|
}
|
|
5087
5151
|
try {
|
|
5088
|
-
await runWindowsRemoteControlPs(lines.join("
|
|
5152
|
+
await runWindowsRemoteControlPs(lines.join("\r\n"));
|
|
5089
5153
|
return { ok: true, action };
|
|
5090
5154
|
}
|
|
5091
5155
|
catch (e) {
|