@midscene/computer 1.13.4-beta-20260928083351.0 → 1.14.0
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/es/cli.mjs +81 -108
- package/dist/es/index.mjs +81 -108
- package/dist/lib/cli.js +81 -108
- package/dist/lib/index.js +81 -108
- package/dist/types/index.d.ts +1 -0
- package/package.json +3 -3
package/dist/lib/cli.js
CHANGED
|
@@ -109,24 +109,6 @@ function sendKeyViaAppleScript(key, modifiers = []) {
|
|
|
109
109
|
script
|
|
110
110
|
]);
|
|
111
111
|
}
|
|
112
|
-
const desktopPointerPolicy = {
|
|
113
|
-
uiSettleMs: 100,
|
|
114
|
-
moveSettleMs: 50,
|
|
115
|
-
defaultTapHoldMs: 100,
|
|
116
|
-
tapMoveSteps: 8,
|
|
117
|
-
tapMoveStepDelayMs: 8,
|
|
118
|
-
hoverMoveSteps: 10,
|
|
119
|
-
hoverMoveStepDelayMs: 10
|
|
120
|
-
};
|
|
121
|
-
const desktopKeyboardPolicy = {
|
|
122
|
-
focusBeforeTypeMs: 300,
|
|
123
|
-
focusBeforeClearMs: 300,
|
|
124
|
-
focusBeforeShortcutMs: 50,
|
|
125
|
-
afterClearMs: 150
|
|
126
|
-
};
|
|
127
|
-
function resolveTapHoldDuration(duration) {
|
|
128
|
-
return Math.max(0, Math.round(duration ?? desktopPointerPolicy.defaultTapHoldMs));
|
|
129
|
-
}
|
|
130
112
|
const external_node_assert_namespaceObject = require("node:assert");
|
|
131
113
|
var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
|
|
132
114
|
function _define_property(obj, key, value) {
|
|
@@ -819,9 +801,18 @@ async function captureScreenshot(options) {
|
|
|
819
801
|
});
|
|
820
802
|
}
|
|
821
803
|
}
|
|
804
|
+
const SMOOTH_MOVE_STEPS_TAP = 8;
|
|
805
|
+
const SMOOTH_MOVE_STEPS_MOUSE_MOVE = 10;
|
|
822
806
|
const SMOOTH_MOVE_STEPS_DRAG = 20;
|
|
807
|
+
const SMOOTH_MOVE_DELAY_TAP = 8;
|
|
808
|
+
const SMOOTH_MOVE_DELAY_MOUSE_MOVE = 10;
|
|
823
809
|
const SMOOTH_MOVE_DELAY_DRAG = 10;
|
|
810
|
+
const MOUSE_MOVE_EFFECT_WAIT = 300;
|
|
811
|
+
const CLICK_SETTLE_DELAY = 50;
|
|
812
|
+
const CLICK_HOLD_DURATION = 100;
|
|
824
813
|
const CLICK_FOCUS_SETTLE_DELAY = 120;
|
|
814
|
+
const INPUT_FOCUS_DELAY = 300;
|
|
815
|
+
const INPUT_CLEAR_DELAY = 150;
|
|
825
816
|
const SCROLL_STEP_DELAY = 100;
|
|
826
817
|
const SCROLL_COMPLETE_DELAY = 500;
|
|
827
818
|
const EDGE_SCROLL_TOTAL_PX = 50000;
|
|
@@ -1142,7 +1133,7 @@ function normalizePrimaryKey(key) {
|
|
|
1142
1133
|
return KEY_NAME_MAP[lowerKey] || lowerKey;
|
|
1143
1134
|
}
|
|
1144
1135
|
class ComputerDevice {
|
|
1145
|
-
async moveGlobalPointer(point, context,
|
|
1136
|
+
async moveGlobalPointer(point, context, smooth) {
|
|
1146
1137
|
if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
|
|
1147
1138
|
const target = {
|
|
1148
1139
|
x: Math.round(point.x),
|
|
@@ -1150,21 +1141,21 @@ class ComputerDevice {
|
|
|
1150
1141
|
};
|
|
1151
1142
|
if ('win32' === process.platform) {
|
|
1152
1143
|
const actual = this.windowsPointerDriver.moveTo(target, {
|
|
1153
|
-
smoothSteps:
|
|
1154
|
-
smoothDelayMs:
|
|
1144
|
+
smoothSteps: smooth?.smoothSteps,
|
|
1145
|
+
smoothDelayMs: smooth?.smoothDelay
|
|
1155
1146
|
});
|
|
1156
1147
|
const drift = windowsPointerDrift(target, actual);
|
|
1157
1148
|
if (!windowsPointerIsWithinTolerance(drift)) throw new Error(`${context}: expected (${target.x}, ${target.y}), got (${actual.x}, ${actual.y}), drift=(${drift.x}, ${drift.y})`);
|
|
1158
|
-
await this.inputDriver.delay(
|
|
1149
|
+
await this.inputDriver.delay(CLICK_SETTLE_DELAY);
|
|
1159
1150
|
return actual;
|
|
1160
1151
|
}
|
|
1161
|
-
if (
|
|
1152
|
+
if (smooth) await this.inputDriver.smoothMoveMouse(target.x, target.y, smooth.smoothSteps, smooth.smoothDelay);
|
|
1162
1153
|
else this.inputDriver.moveMouse(target.x, target.y);
|
|
1163
|
-
await this.inputDriver.delay(
|
|
1154
|
+
await this.inputDriver.delay(CLICK_SETTLE_DELAY);
|
|
1164
1155
|
return this.inputDriver.getMousePos();
|
|
1165
1156
|
}
|
|
1166
|
-
moveDisplayPointer(point, context,
|
|
1167
|
-
return this.moveGlobalPointer(this.toGlobalPoint(point), context,
|
|
1157
|
+
moveDisplayPointer(point, context, smooth) {
|
|
1158
|
+
return this.moveGlobalPointer(this.toGlobalPoint(point), context, smooth);
|
|
1168
1159
|
}
|
|
1169
1160
|
async performPointerDrag(from, to, duration) {
|
|
1170
1161
|
const screenSize = await this.size();
|
|
@@ -1190,9 +1181,7 @@ class ComputerDevice {
|
|
|
1190
1181
|
await this.moveDisplayPointer({
|
|
1191
1182
|
x,
|
|
1192
1183
|
y
|
|
1193
|
-
}, 'Mouse did not reach the keyboard focus target'
|
|
1194
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1195
|
-
});
|
|
1184
|
+
}, 'Mouse did not reach the keyboard focus target');
|
|
1196
1185
|
this.inputDriver.mouseClick('left');
|
|
1197
1186
|
}
|
|
1198
1187
|
await this.inputDriver.delay(delayMs);
|
|
@@ -1274,7 +1263,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1274
1263
|
}
|
|
1275
1264
|
async healthCheck(displays) {
|
|
1276
1265
|
console.log('[HealthCheck] Starting health check...');
|
|
1277
|
-
console.log("[HealthCheck] @midscene/computer v1.
|
|
1266
|
+
console.log("[HealthCheck] @midscene/computer v1.14.0");
|
|
1278
1267
|
console.log('[HealthCheck] Taking screenshot...');
|
|
1279
1268
|
const screenshotTimeout = 15000;
|
|
1280
1269
|
let timeoutId;
|
|
@@ -1312,7 +1301,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1312
1301
|
console.log(`[HealthCheck] Moving mouse to (${targetX}, ${targetY})...`);
|
|
1313
1302
|
try {
|
|
1314
1303
|
this.inputDriver.moveMouse(targetX, targetY);
|
|
1315
|
-
await (0, utils_namespaceObject.sleep)(
|
|
1304
|
+
await (0, utils_namespaceObject.sleep)(CLICK_SETTLE_DELAY);
|
|
1316
1305
|
this.inputDriver.assertMousePosition(targetX, targetY, 'Mouse health check failed');
|
|
1317
1306
|
} finally{
|
|
1318
1307
|
this.inputDriver.moveMouse(startPos.x, startPos.y);
|
|
@@ -1547,9 +1536,8 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1547
1536
|
const screenSize = await this.size();
|
|
1548
1537
|
if ('win32' === process.platform && this.inputDriver.focusActiveWindow()) await this.inputDriver.delay(CLICK_FOCUS_SETTLE_DELAY);
|
|
1549
1538
|
const point = this.resolveUntargetedScrollPoint(screenSize);
|
|
1550
|
-
await this.moveGlobalPointer(point, 'Mouse did not reach the scroll viewport'
|
|
1551
|
-
|
|
1552
|
-
});
|
|
1539
|
+
await this.moveGlobalPointer(point, 'Mouse did not reach the scroll viewport');
|
|
1540
|
+
await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
|
|
1553
1541
|
return screenSize;
|
|
1554
1542
|
}
|
|
1555
1543
|
async performScroll(param) {
|
|
@@ -1690,7 +1678,7 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1690
1678
|
});
|
|
1691
1679
|
const targetX = Math.round(target.x);
|
|
1692
1680
|
const targetY = Math.round(target.y);
|
|
1693
|
-
const holdDuration =
|
|
1681
|
+
const holdDuration = Math.max(0, Math.round(opts?.duration ?? CLICK_HOLD_DURATION));
|
|
1694
1682
|
debugComputerInput('tap start %o', {
|
|
1695
1683
|
local: {
|
|
1696
1684
|
x,
|
|
@@ -1709,9 +1697,8 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1709
1697
|
x: targetX,
|
|
1710
1698
|
y: targetY
|
|
1711
1699
|
}, 'Mouse did not reach the tap target', {
|
|
1712
|
-
smoothSteps:
|
|
1713
|
-
smoothDelay:
|
|
1714
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1700
|
+
smoothSteps: SMOOTH_MOVE_STEPS_TAP,
|
|
1701
|
+
smoothDelay: SMOOTH_MOVE_DELAY_TAP
|
|
1715
1702
|
});
|
|
1716
1703
|
await pressMouseAtGlobalPoint(this.inputDriver, targetX, targetY, current, holdDuration, 'primary');
|
|
1717
1704
|
if (frontmostBefore && 'darwin' === process.platform) {
|
|
@@ -1727,9 +1714,7 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1727
1714
|
const followUpCurrent = await this.moveGlobalPointer({
|
|
1728
1715
|
x: targetX,
|
|
1729
1716
|
y: targetY
|
|
1730
|
-
}, 'Mouse did not reach the focus follow-up target'
|
|
1731
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1732
|
-
});
|
|
1717
|
+
}, 'Mouse did not reach the focus follow-up target');
|
|
1733
1718
|
await pressMouseAtGlobalPoint(this.inputDriver, targetX, targetY, followUpCurrent, holdDuration, 'focus-follow-up');
|
|
1734
1719
|
}
|
|
1735
1720
|
}
|
|
@@ -1738,18 +1723,14 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1738
1723
|
await this.moveDisplayPointer({
|
|
1739
1724
|
x,
|
|
1740
1725
|
y
|
|
1741
|
-
}, 'Mouse did not reach the double-click target'
|
|
1742
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1743
|
-
});
|
|
1726
|
+
}, 'Mouse did not reach the double-click target');
|
|
1744
1727
|
this.inputDriver.mouseClick('left', true);
|
|
1745
1728
|
},
|
|
1746
1729
|
rightClick: async ({ x, y })=>{
|
|
1747
1730
|
await this.moveDisplayPointer({
|
|
1748
1731
|
x,
|
|
1749
1732
|
y
|
|
1750
|
-
}, 'Mouse did not reach the right-click target'
|
|
1751
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1752
|
-
});
|
|
1733
|
+
}, 'Mouse did not reach the right-click target');
|
|
1753
1734
|
this.inputDriver.mouseClick('right');
|
|
1754
1735
|
},
|
|
1755
1736
|
hover: async ({ x, y })=>{
|
|
@@ -1757,10 +1738,10 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1757
1738
|
x,
|
|
1758
1739
|
y
|
|
1759
1740
|
}, 'Mouse did not reach the hover target', {
|
|
1760
|
-
smoothSteps:
|
|
1761
|
-
smoothDelay:
|
|
1762
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1741
|
+
smoothSteps: SMOOTH_MOVE_STEPS_MOUSE_MOVE,
|
|
1742
|
+
smoothDelay: SMOOTH_MOVE_DELAY_MOUSE_MOVE
|
|
1763
1743
|
});
|
|
1744
|
+
await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
|
|
1764
1745
|
},
|
|
1765
1746
|
dragAndDrop: async (from, to)=>{
|
|
1766
1747
|
await this.performPointerDrag(from, to);
|
|
@@ -1775,25 +1756,23 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1775
1756
|
const resolvedInputOptions = (0, device_namespaceObject.resolveTextInputOptions)(opts, this.options);
|
|
1776
1757
|
const element = opts?.target;
|
|
1777
1758
|
if (element) {
|
|
1778
|
-
await this.focusKeyboardTarget(element,
|
|
1779
|
-
if (opts?.focusOnly) return;
|
|
1759
|
+
await this.focusKeyboardTarget(element, INPUT_FOCUS_DELAY);
|
|
1780
1760
|
if (opts?.replace !== false) {
|
|
1781
1761
|
await this.selectAllAndDelete();
|
|
1782
|
-
await this.inputDriver.delay(
|
|
1762
|
+
await this.inputDriver.delay(INPUT_CLEAR_DELAY);
|
|
1783
1763
|
}
|
|
1784
1764
|
}
|
|
1785
|
-
if (opts?.focusOnly || !value) return;
|
|
1786
1765
|
await this.smartTypeString(value, resolvedInputOptions);
|
|
1787
1766
|
},
|
|
1788
1767
|
keyboardPress: async (keyName, opts)=>{
|
|
1789
1768
|
const target = opts?.target;
|
|
1790
|
-
if (target) await this.focusKeyboardTarget(target,
|
|
1769
|
+
if (target) await this.focusKeyboardTarget(target, 50);
|
|
1791
1770
|
await this.pressKeyboardShortcut(keyName);
|
|
1792
1771
|
},
|
|
1793
1772
|
clearInput: async (target)=>{
|
|
1794
|
-
if (target) await this.focusKeyboardTarget(target,
|
|
1773
|
+
if (target) await this.focusKeyboardTarget(target, 100);
|
|
1795
1774
|
await this.selectAllAndDelete();
|
|
1796
|
-
await this.inputDriver.delay(
|
|
1775
|
+
await this.inputDriver.delay(50);
|
|
1797
1776
|
}
|
|
1798
1777
|
},
|
|
1799
1778
|
scroll: {
|
|
@@ -2207,9 +2186,17 @@ function rdp_device_define_property(obj, key, value) {
|
|
|
2207
2186
|
return obj;
|
|
2208
2187
|
}
|
|
2209
2188
|
const device_debug = (0, logger_namespaceObject.getDebug)('rdp:device');
|
|
2189
|
+
const device_SMOOTH_MOVE_STEPS_TAP = 8;
|
|
2190
|
+
const device_SMOOTH_MOVE_STEPS_MOUSE_MOVE = 10;
|
|
2210
2191
|
const device_SMOOTH_MOVE_STEPS_DRAG = 12;
|
|
2192
|
+
const device_SMOOTH_MOVE_DELAY_TAP = 8;
|
|
2193
|
+
const device_SMOOTH_MOVE_DELAY_MOUSE_MOVE = 10;
|
|
2211
2194
|
const device_SMOOTH_MOVE_DELAY_DRAG = 10;
|
|
2195
|
+
const device_MOUSE_MOVE_EFFECT_WAIT = 300;
|
|
2196
|
+
const device_CLICK_HOLD_DURATION = 50;
|
|
2212
2197
|
const DRAG_HOLD_DURATION = 100;
|
|
2198
|
+
const device_INPUT_FOCUS_DELAY = 300;
|
|
2199
|
+
const device_INPUT_CLEAR_DELAY = 150;
|
|
2213
2200
|
const device_SCROLL_STEP_DELAY = 100;
|
|
2214
2201
|
const device_SCROLL_COMPLETE_DELAY = 500;
|
|
2215
2202
|
const DEFAULT_SCROLL_DISTANCE = 480;
|
|
@@ -2295,6 +2282,12 @@ class RDPDevice {
|
|
|
2295
2282
|
throwIfDestroyed() {
|
|
2296
2283
|
if (this.destroyed) throw new Error('RDPDevice has been destroyed');
|
|
2297
2284
|
}
|
|
2285
|
+
async moveToElement(element, options) {
|
|
2286
|
+
this.assertConnected();
|
|
2287
|
+
const targetX = Math.round(element.center[0]);
|
|
2288
|
+
const targetY = Math.round(element.center[1]);
|
|
2289
|
+
await this.movePointer(targetX, targetY, options);
|
|
2290
|
+
}
|
|
2298
2291
|
async clearInput() {
|
|
2299
2292
|
if (this.backend.clearInput) return void await this.backend.clearInput();
|
|
2300
2293
|
await this.backend.keyPress('Control+A');
|
|
@@ -2348,8 +2341,8 @@ class RDPDevice {
|
|
|
2348
2341
|
const boundedFrom = clampPointerPointToSize(from, screenSize);
|
|
2349
2342
|
const boundedTo = clampPointerPointToSize(to, screenSize);
|
|
2350
2343
|
await this.movePointer(Math.round(boundedFrom.x), Math.round(boundedFrom.y), {
|
|
2351
|
-
steps:
|
|
2352
|
-
stepDelayMs:
|
|
2344
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2345
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2353
2346
|
});
|
|
2354
2347
|
await this.backend.mouseButton('left', 'down');
|
|
2355
2348
|
try {
|
|
@@ -2385,40 +2378,34 @@ class RDPDevice {
|
|
|
2385
2378
|
rdp_device_define_property(this, "uri", void 0);
|
|
2386
2379
|
rdp_device_define_property(this, "inputPrimitives", {
|
|
2387
2380
|
pointer: {
|
|
2388
|
-
tap: async ({ x, y }
|
|
2381
|
+
tap: async ({ x, y })=>{
|
|
2389
2382
|
await this.movePointer(Math.round(x), Math.round(y), {
|
|
2390
|
-
steps:
|
|
2391
|
-
stepDelayMs:
|
|
2392
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
2383
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2384
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2393
2385
|
});
|
|
2394
2386
|
await this.backend.mouseButton('left', 'down');
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
} finally{
|
|
2398
|
-
await this.backend.mouseButton('left', 'up');
|
|
2399
|
-
}
|
|
2387
|
+
await (0, utils_namespaceObject.sleep)(device_CLICK_HOLD_DURATION);
|
|
2388
|
+
await this.backend.mouseButton('left', 'up');
|
|
2400
2389
|
},
|
|
2401
2390
|
doubleClick: async ({ x, y })=>{
|
|
2402
2391
|
await this.movePointer(Math.round(x), Math.round(y), {
|
|
2403
|
-
steps:
|
|
2404
|
-
stepDelayMs:
|
|
2405
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
2392
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2393
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2406
2394
|
});
|
|
2407
2395
|
await this.backend.mouseButton('left', 'doubleClick');
|
|
2408
2396
|
},
|
|
2409
2397
|
rightClick: async ({ x, y })=>{
|
|
2410
2398
|
await this.movePointer(Math.round(x), Math.round(y), {
|
|
2411
|
-
steps:
|
|
2412
|
-
stepDelayMs:
|
|
2413
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
2399
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2400
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2414
2401
|
});
|
|
2415
2402
|
await this.backend.mouseButton('right', 'click');
|
|
2416
2403
|
},
|
|
2417
2404
|
hover: async ({ x, y })=>{
|
|
2418
2405
|
await this.movePointer(Math.round(x), Math.round(y), {
|
|
2419
|
-
steps:
|
|
2420
|
-
stepDelayMs:
|
|
2421
|
-
settleDelayMs:
|
|
2406
|
+
steps: device_SMOOTH_MOVE_STEPS_MOUSE_MOVE,
|
|
2407
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_MOUSE_MOVE,
|
|
2408
|
+
settleDelayMs: device_MOUSE_MOVE_EFFECT_WAIT
|
|
2422
2409
|
});
|
|
2423
2410
|
},
|
|
2424
2411
|
dragAndDrop: async (from, to)=>{
|
|
@@ -2439,12 +2426,11 @@ class RDPDevice {
|
|
|
2439
2426
|
x: target.center[0],
|
|
2440
2427
|
y: target.center[1]
|
|
2441
2428
|
});
|
|
2442
|
-
await (0, utils_namespaceObject.sleep)(
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
}
|
|
2429
|
+
await (0, utils_namespaceObject.sleep)(device_INPUT_FOCUS_DELAY);
|
|
2430
|
+
}
|
|
2431
|
+
if (opts?.replace !== false) {
|
|
2432
|
+
await this.clearInput();
|
|
2433
|
+
await (0, utils_namespaceObject.sleep)(device_INPUT_CLEAR_DELAY);
|
|
2448
2434
|
}
|
|
2449
2435
|
if (opts?.focusOnly || !value) return;
|
|
2450
2436
|
await this.typeText(value, resolvedInputOptions);
|
|
@@ -2457,21 +2443,18 @@ class RDPDevice {
|
|
|
2457
2443
|
x: element.center[0],
|
|
2458
2444
|
y: element.center[1]
|
|
2459
2445
|
});
|
|
2460
|
-
await (0, utils_namespaceObject.sleep)(
|
|
2446
|
+
await (0, utils_namespaceObject.sleep)(device_INPUT_FOCUS_DELAY);
|
|
2461
2447
|
}
|
|
2462
2448
|
await this.clearInput();
|
|
2463
|
-
await (0, utils_namespaceObject.sleep)(
|
|
2449
|
+
await (0, utils_namespaceObject.sleep)(device_INPUT_CLEAR_DELAY);
|
|
2464
2450
|
},
|
|
2465
2451
|
keyboardPress: async (keyName, opts)=>{
|
|
2466
2452
|
this.assertConnected();
|
|
2467
2453
|
const target = opts?.target;
|
|
2468
|
-
if (target) {
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
});
|
|
2473
|
-
await (0, utils_namespaceObject.sleep)(desktopKeyboardPolicy.focusBeforeShortcutMs);
|
|
2474
|
-
}
|
|
2454
|
+
if (target) await this.inputPrimitives.pointer.tap({
|
|
2455
|
+
x: target.center[0],
|
|
2456
|
+
y: target.center[1]
|
|
2457
|
+
});
|
|
2475
2458
|
await this.backend.keyPress(keyName);
|
|
2476
2459
|
}
|
|
2477
2460
|
},
|
|
@@ -2479,27 +2462,17 @@ class RDPDevice {
|
|
|
2479
2462
|
scroll: async (param)=>{
|
|
2480
2463
|
this.assertConnected();
|
|
2481
2464
|
const target = param.locate;
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
const size = await this.size();
|
|
2486
|
-
scrollPoint = [
|
|
2487
|
-
Math.round(size.width / 2),
|
|
2488
|
-
Math.round(size.height / 2)
|
|
2489
|
-
];
|
|
2490
|
-
}
|
|
2491
|
-
await this.movePointer(Math.round(scrollPoint[0]), Math.round(scrollPoint[1]), {
|
|
2492
|
-
steps: desktopPointerPolicy.hoverMoveSteps,
|
|
2493
|
-
stepDelayMs: desktopPointerPolicy.hoverMoveStepDelayMs,
|
|
2494
|
-
settleDelayMs: target ? desktopPointerPolicy.moveSettleMs : desktopPointerPolicy.uiSettleMs
|
|
2465
|
+
if (target) await this.moveToElement(target, {
|
|
2466
|
+
steps: device_SMOOTH_MOVE_STEPS_MOUSE_MOVE,
|
|
2467
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_MOUSE_MOVE
|
|
2495
2468
|
});
|
|
2496
2469
|
if (param.scrollType && 'singleAction' !== param.scrollType) {
|
|
2497
2470
|
const direction = this.edgeScrollDirection(param.scrollType);
|
|
2498
|
-
for(let i = 0; i < device_EDGE_SCROLL_STEPS; i++)await this.performWheel(direction, DEFAULT_SCROLL_DISTANCE,
|
|
2471
|
+
for(let i = 0; i < device_EDGE_SCROLL_STEPS; i++)await this.performWheel(direction, DEFAULT_SCROLL_DISTANCE, target?.center[0], target?.center[1]);
|
|
2499
2472
|
await (0, utils_namespaceObject.sleep)(device_SCROLL_COMPLETE_DELAY);
|
|
2500
2473
|
return;
|
|
2501
2474
|
}
|
|
2502
|
-
await this.performWheel(param.direction || 'down', param.distance || this.defaultScrollDistance(param.direction || 'down'),
|
|
2475
|
+
await this.performWheel(param.direction || 'down', param.distance || this.defaultScrollDistance(param.direction || 'down'), target?.center[0], target?.center[1]);
|
|
2503
2476
|
await (0, utils_namespaceObject.sleep)(device_SCROLL_COMPLETE_DELAY);
|
|
2504
2477
|
}
|
|
2505
2478
|
}
|
|
@@ -2780,7 +2753,7 @@ const tools = new ComputerMidsceneTools({
|
|
|
2780
2753
|
});
|
|
2781
2754
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-computer', {
|
|
2782
2755
|
stripPrefix: 'computer_',
|
|
2783
|
-
version: "1.
|
|
2756
|
+
version: "1.14.0",
|
|
2784
2757
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
2785
2758
|
}).catch((e)=>{
|
|
2786
2759
|
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|