@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/index.js
CHANGED
|
@@ -135,24 +135,6 @@ function sendKeyViaAppleScript(key, modifiers = []) {
|
|
|
135
135
|
script
|
|
136
136
|
]);
|
|
137
137
|
}
|
|
138
|
-
const desktopPointerPolicy = {
|
|
139
|
-
uiSettleMs: 100,
|
|
140
|
-
moveSettleMs: 50,
|
|
141
|
-
defaultTapHoldMs: 100,
|
|
142
|
-
tapMoveSteps: 8,
|
|
143
|
-
tapMoveStepDelayMs: 8,
|
|
144
|
-
hoverMoveSteps: 10,
|
|
145
|
-
hoverMoveStepDelayMs: 10
|
|
146
|
-
};
|
|
147
|
-
const desktopKeyboardPolicy = {
|
|
148
|
-
focusBeforeTypeMs: 300,
|
|
149
|
-
focusBeforeClearMs: 300,
|
|
150
|
-
focusBeforeShortcutMs: 50,
|
|
151
|
-
afterClearMs: 150
|
|
152
|
-
};
|
|
153
|
-
function resolveTapHoldDuration(duration) {
|
|
154
|
-
return Math.max(0, Math.round(duration ?? desktopPointerPolicy.defaultTapHoldMs));
|
|
155
|
-
}
|
|
156
138
|
const external_node_assert_namespaceObject = require("node:assert");
|
|
157
139
|
var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
|
|
158
140
|
function _define_property(obj, key, value) {
|
|
@@ -845,9 +827,18 @@ async function captureScreenshot(options) {
|
|
|
845
827
|
});
|
|
846
828
|
}
|
|
847
829
|
}
|
|
830
|
+
const SMOOTH_MOVE_STEPS_TAP = 8;
|
|
831
|
+
const SMOOTH_MOVE_STEPS_MOUSE_MOVE = 10;
|
|
848
832
|
const SMOOTH_MOVE_STEPS_DRAG = 20;
|
|
833
|
+
const SMOOTH_MOVE_DELAY_TAP = 8;
|
|
834
|
+
const SMOOTH_MOVE_DELAY_MOUSE_MOVE = 10;
|
|
849
835
|
const SMOOTH_MOVE_DELAY_DRAG = 10;
|
|
836
|
+
const MOUSE_MOVE_EFFECT_WAIT = 300;
|
|
837
|
+
const CLICK_SETTLE_DELAY = 50;
|
|
838
|
+
const CLICK_HOLD_DURATION = 100;
|
|
850
839
|
const CLICK_FOCUS_SETTLE_DELAY = 120;
|
|
840
|
+
const INPUT_FOCUS_DELAY = 300;
|
|
841
|
+
const INPUT_CLEAR_DELAY = 150;
|
|
851
842
|
const SCROLL_STEP_DELAY = 100;
|
|
852
843
|
const SCROLL_COMPLETE_DELAY = 500;
|
|
853
844
|
const EDGE_SCROLL_TOTAL_PX = 50000;
|
|
@@ -1168,7 +1159,7 @@ function normalizePrimaryKey(key) {
|
|
|
1168
1159
|
return KEY_NAME_MAP[lowerKey] || lowerKey;
|
|
1169
1160
|
}
|
|
1170
1161
|
class ComputerDevice {
|
|
1171
|
-
async moveGlobalPointer(point, context,
|
|
1162
|
+
async moveGlobalPointer(point, context, smooth) {
|
|
1172
1163
|
if (this.destroyed) throw new Error('ComputerDevice has been destroyed');
|
|
1173
1164
|
const target = {
|
|
1174
1165
|
x: Math.round(point.x),
|
|
@@ -1176,21 +1167,21 @@ class ComputerDevice {
|
|
|
1176
1167
|
};
|
|
1177
1168
|
if ('win32' === process.platform) {
|
|
1178
1169
|
const actual = this.windowsPointerDriver.moveTo(target, {
|
|
1179
|
-
smoothSteps:
|
|
1180
|
-
smoothDelayMs:
|
|
1170
|
+
smoothSteps: smooth?.smoothSteps,
|
|
1171
|
+
smoothDelayMs: smooth?.smoothDelay
|
|
1181
1172
|
});
|
|
1182
1173
|
const drift = windowsPointerDrift(target, actual);
|
|
1183
1174
|
if (!windowsPointerIsWithinTolerance(drift)) throw new Error(`${context}: expected (${target.x}, ${target.y}), got (${actual.x}, ${actual.y}), drift=(${drift.x}, ${drift.y})`);
|
|
1184
|
-
await this.inputDriver.delay(
|
|
1175
|
+
await this.inputDriver.delay(CLICK_SETTLE_DELAY);
|
|
1185
1176
|
return actual;
|
|
1186
1177
|
}
|
|
1187
|
-
if (
|
|
1178
|
+
if (smooth) await this.inputDriver.smoothMoveMouse(target.x, target.y, smooth.smoothSteps, smooth.smoothDelay);
|
|
1188
1179
|
else this.inputDriver.moveMouse(target.x, target.y);
|
|
1189
|
-
await this.inputDriver.delay(
|
|
1180
|
+
await this.inputDriver.delay(CLICK_SETTLE_DELAY);
|
|
1190
1181
|
return this.inputDriver.getMousePos();
|
|
1191
1182
|
}
|
|
1192
|
-
moveDisplayPointer(point, context,
|
|
1193
|
-
return this.moveGlobalPointer(this.toGlobalPoint(point), context,
|
|
1183
|
+
moveDisplayPointer(point, context, smooth) {
|
|
1184
|
+
return this.moveGlobalPointer(this.toGlobalPoint(point), context, smooth);
|
|
1194
1185
|
}
|
|
1195
1186
|
async performPointerDrag(from, to, duration) {
|
|
1196
1187
|
const screenSize = await this.size();
|
|
@@ -1216,9 +1207,7 @@ class ComputerDevice {
|
|
|
1216
1207
|
await this.moveDisplayPointer({
|
|
1217
1208
|
x,
|
|
1218
1209
|
y
|
|
1219
|
-
}, 'Mouse did not reach the keyboard focus target'
|
|
1220
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1221
|
-
});
|
|
1210
|
+
}, 'Mouse did not reach the keyboard focus target');
|
|
1222
1211
|
this.inputDriver.mouseClick('left');
|
|
1223
1212
|
}
|
|
1224
1213
|
await this.inputDriver.delay(delayMs);
|
|
@@ -1300,7 +1289,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1300
1289
|
}
|
|
1301
1290
|
async healthCheck(displays) {
|
|
1302
1291
|
console.log('[HealthCheck] Starting health check...');
|
|
1303
|
-
console.log("[HealthCheck] @midscene/computer v1.
|
|
1292
|
+
console.log("[HealthCheck] @midscene/computer v1.14.0");
|
|
1304
1293
|
console.log('[HealthCheck] Taking screenshot...');
|
|
1305
1294
|
const screenshotTimeout = 15000;
|
|
1306
1295
|
let timeoutId;
|
|
@@ -1338,7 +1327,7 @@ Available Displays: ${displays.length > 0 ? displays.map((d)=>d.name).join(', ')
|
|
|
1338
1327
|
console.log(`[HealthCheck] Moving mouse to (${targetX}, ${targetY})...`);
|
|
1339
1328
|
try {
|
|
1340
1329
|
this.inputDriver.moveMouse(targetX, targetY);
|
|
1341
|
-
await (0, utils_namespaceObject.sleep)(
|
|
1330
|
+
await (0, utils_namespaceObject.sleep)(CLICK_SETTLE_DELAY);
|
|
1342
1331
|
this.inputDriver.assertMousePosition(targetX, targetY, 'Mouse health check failed');
|
|
1343
1332
|
} finally{
|
|
1344
1333
|
this.inputDriver.moveMouse(startPos.x, startPos.y);
|
|
@@ -1573,9 +1562,8 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1573
1562
|
const screenSize = await this.size();
|
|
1574
1563
|
if ('win32' === process.platform && this.inputDriver.focusActiveWindow()) await this.inputDriver.delay(CLICK_FOCUS_SETTLE_DELAY);
|
|
1575
1564
|
const point = this.resolveUntargetedScrollPoint(screenSize);
|
|
1576
|
-
await this.moveGlobalPointer(point, 'Mouse did not reach the scroll viewport'
|
|
1577
|
-
|
|
1578
|
-
});
|
|
1565
|
+
await this.moveGlobalPointer(point, 'Mouse did not reach the scroll viewport');
|
|
1566
|
+
await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
|
|
1579
1567
|
return screenSize;
|
|
1580
1568
|
}
|
|
1581
1569
|
async performScroll(param) {
|
|
@@ -1716,7 +1704,7 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1716
1704
|
});
|
|
1717
1705
|
const targetX = Math.round(target.x);
|
|
1718
1706
|
const targetY = Math.round(target.y);
|
|
1719
|
-
const holdDuration =
|
|
1707
|
+
const holdDuration = Math.max(0, Math.round(opts?.duration ?? CLICK_HOLD_DURATION));
|
|
1720
1708
|
debugComputerInput('tap start %o', {
|
|
1721
1709
|
local: {
|
|
1722
1710
|
x,
|
|
@@ -1735,9 +1723,8 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1735
1723
|
x: targetX,
|
|
1736
1724
|
y: targetY
|
|
1737
1725
|
}, 'Mouse did not reach the tap target', {
|
|
1738
|
-
smoothSteps:
|
|
1739
|
-
smoothDelay:
|
|
1740
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1726
|
+
smoothSteps: SMOOTH_MOVE_STEPS_TAP,
|
|
1727
|
+
smoothDelay: SMOOTH_MOVE_DELAY_TAP
|
|
1741
1728
|
});
|
|
1742
1729
|
await pressMouseAtGlobalPoint(this.inputDriver, targetX, targetY, current, holdDuration, 'primary');
|
|
1743
1730
|
if (frontmostBefore && 'darwin' === process.platform) {
|
|
@@ -1753,9 +1740,7 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1753
1740
|
const followUpCurrent = await this.moveGlobalPointer({
|
|
1754
1741
|
x: targetX,
|
|
1755
1742
|
y: targetY
|
|
1756
|
-
}, 'Mouse did not reach the focus follow-up target'
|
|
1757
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1758
|
-
});
|
|
1743
|
+
}, 'Mouse did not reach the focus follow-up target');
|
|
1759
1744
|
await pressMouseAtGlobalPoint(this.inputDriver, targetX, targetY, followUpCurrent, holdDuration, 'focus-follow-up');
|
|
1760
1745
|
}
|
|
1761
1746
|
}
|
|
@@ -1764,18 +1749,14 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1764
1749
|
await this.moveDisplayPointer({
|
|
1765
1750
|
x,
|
|
1766
1751
|
y
|
|
1767
|
-
}, 'Mouse did not reach the double-click target'
|
|
1768
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1769
|
-
});
|
|
1752
|
+
}, 'Mouse did not reach the double-click target');
|
|
1770
1753
|
this.inputDriver.mouseClick('left', true);
|
|
1771
1754
|
},
|
|
1772
1755
|
rightClick: async ({ x, y })=>{
|
|
1773
1756
|
await this.moveDisplayPointer({
|
|
1774
1757
|
x,
|
|
1775
1758
|
y
|
|
1776
|
-
}, 'Mouse did not reach the right-click target'
|
|
1777
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1778
|
-
});
|
|
1759
|
+
}, 'Mouse did not reach the right-click target');
|
|
1779
1760
|
this.inputDriver.mouseClick('right');
|
|
1780
1761
|
},
|
|
1781
1762
|
hover: async ({ x, y })=>{
|
|
@@ -1783,10 +1764,10 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1783
1764
|
x,
|
|
1784
1765
|
y
|
|
1785
1766
|
}, 'Mouse did not reach the hover target', {
|
|
1786
|
-
smoothSteps:
|
|
1787
|
-
smoothDelay:
|
|
1788
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
1767
|
+
smoothSteps: SMOOTH_MOVE_STEPS_MOUSE_MOVE,
|
|
1768
|
+
smoothDelay: SMOOTH_MOVE_DELAY_MOUSE_MOVE
|
|
1789
1769
|
});
|
|
1770
|
+
await this.inputDriver.delay(MOUSE_MOVE_EFFECT_WAIT);
|
|
1790
1771
|
},
|
|
1791
1772
|
dragAndDrop: async (from, to)=>{
|
|
1792
1773
|
await this.performPointerDrag(from, to);
|
|
@@ -1801,25 +1782,23 @@ $g.Dispose(); $bmp.Dispose(); $ms.Dispose()
|
|
|
1801
1782
|
const resolvedInputOptions = (0, device_namespaceObject.resolveTextInputOptions)(opts, this.options);
|
|
1802
1783
|
const element = opts?.target;
|
|
1803
1784
|
if (element) {
|
|
1804
|
-
await this.focusKeyboardTarget(element,
|
|
1805
|
-
if (opts?.focusOnly) return;
|
|
1785
|
+
await this.focusKeyboardTarget(element, INPUT_FOCUS_DELAY);
|
|
1806
1786
|
if (opts?.replace !== false) {
|
|
1807
1787
|
await this.selectAllAndDelete();
|
|
1808
|
-
await this.inputDriver.delay(
|
|
1788
|
+
await this.inputDriver.delay(INPUT_CLEAR_DELAY);
|
|
1809
1789
|
}
|
|
1810
1790
|
}
|
|
1811
|
-
if (opts?.focusOnly || !value) return;
|
|
1812
1791
|
await this.smartTypeString(value, resolvedInputOptions);
|
|
1813
1792
|
},
|
|
1814
1793
|
keyboardPress: async (keyName, opts)=>{
|
|
1815
1794
|
const target = opts?.target;
|
|
1816
|
-
if (target) await this.focusKeyboardTarget(target,
|
|
1795
|
+
if (target) await this.focusKeyboardTarget(target, 50);
|
|
1817
1796
|
await this.pressKeyboardShortcut(keyName);
|
|
1818
1797
|
},
|
|
1819
1798
|
clearInput: async (target)=>{
|
|
1820
|
-
if (target) await this.focusKeyboardTarget(target,
|
|
1799
|
+
if (target) await this.focusKeyboardTarget(target, 100);
|
|
1821
1800
|
await this.selectAllAndDelete();
|
|
1822
|
-
await this.inputDriver.delay(
|
|
1801
|
+
await this.inputDriver.delay(50);
|
|
1823
1802
|
}
|
|
1824
1803
|
},
|
|
1825
1804
|
scroll: {
|
|
@@ -2277,9 +2256,17 @@ function rdp_device_define_property(obj, key, value) {
|
|
|
2277
2256
|
return obj;
|
|
2278
2257
|
}
|
|
2279
2258
|
const device_debug = (0, logger_namespaceObject.getDebug)('rdp:device');
|
|
2259
|
+
const device_SMOOTH_MOVE_STEPS_TAP = 8;
|
|
2260
|
+
const device_SMOOTH_MOVE_STEPS_MOUSE_MOVE = 10;
|
|
2280
2261
|
const device_SMOOTH_MOVE_STEPS_DRAG = 12;
|
|
2262
|
+
const device_SMOOTH_MOVE_DELAY_TAP = 8;
|
|
2263
|
+
const device_SMOOTH_MOVE_DELAY_MOUSE_MOVE = 10;
|
|
2281
2264
|
const device_SMOOTH_MOVE_DELAY_DRAG = 10;
|
|
2265
|
+
const device_MOUSE_MOVE_EFFECT_WAIT = 300;
|
|
2266
|
+
const device_CLICK_HOLD_DURATION = 50;
|
|
2282
2267
|
const DRAG_HOLD_DURATION = 100;
|
|
2268
|
+
const device_INPUT_FOCUS_DELAY = 300;
|
|
2269
|
+
const device_INPUT_CLEAR_DELAY = 150;
|
|
2283
2270
|
const device_SCROLL_STEP_DELAY = 100;
|
|
2284
2271
|
const device_SCROLL_COMPLETE_DELAY = 500;
|
|
2285
2272
|
const DEFAULT_SCROLL_DISTANCE = 480;
|
|
@@ -2365,6 +2352,12 @@ class RDPDevice {
|
|
|
2365
2352
|
throwIfDestroyed() {
|
|
2366
2353
|
if (this.destroyed) throw new Error('RDPDevice has been destroyed');
|
|
2367
2354
|
}
|
|
2355
|
+
async moveToElement(element, options) {
|
|
2356
|
+
this.assertConnected();
|
|
2357
|
+
const targetX = Math.round(element.center[0]);
|
|
2358
|
+
const targetY = Math.round(element.center[1]);
|
|
2359
|
+
await this.movePointer(targetX, targetY, options);
|
|
2360
|
+
}
|
|
2368
2361
|
async clearInput() {
|
|
2369
2362
|
if (this.backend.clearInput) return void await this.backend.clearInput();
|
|
2370
2363
|
await this.backend.keyPress('Control+A');
|
|
@@ -2418,8 +2411,8 @@ class RDPDevice {
|
|
|
2418
2411
|
const boundedFrom = clampPointerPointToSize(from, screenSize);
|
|
2419
2412
|
const boundedTo = clampPointerPointToSize(to, screenSize);
|
|
2420
2413
|
await this.movePointer(Math.round(boundedFrom.x), Math.round(boundedFrom.y), {
|
|
2421
|
-
steps:
|
|
2422
|
-
stepDelayMs:
|
|
2414
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2415
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2423
2416
|
});
|
|
2424
2417
|
await this.backend.mouseButton('left', 'down');
|
|
2425
2418
|
try {
|
|
@@ -2455,40 +2448,34 @@ class RDPDevice {
|
|
|
2455
2448
|
rdp_device_define_property(this, "uri", void 0);
|
|
2456
2449
|
rdp_device_define_property(this, "inputPrimitives", {
|
|
2457
2450
|
pointer: {
|
|
2458
|
-
tap: async ({ x, y }
|
|
2451
|
+
tap: async ({ x, y })=>{
|
|
2459
2452
|
await this.movePointer(Math.round(x), Math.round(y), {
|
|
2460
|
-
steps:
|
|
2461
|
-
stepDelayMs:
|
|
2462
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
2453
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2454
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2463
2455
|
});
|
|
2464
2456
|
await this.backend.mouseButton('left', 'down');
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
} finally{
|
|
2468
|
-
await this.backend.mouseButton('left', 'up');
|
|
2469
|
-
}
|
|
2457
|
+
await (0, utils_namespaceObject.sleep)(device_CLICK_HOLD_DURATION);
|
|
2458
|
+
await this.backend.mouseButton('left', 'up');
|
|
2470
2459
|
},
|
|
2471
2460
|
doubleClick: async ({ x, y })=>{
|
|
2472
2461
|
await this.movePointer(Math.round(x), Math.round(y), {
|
|
2473
|
-
steps:
|
|
2474
|
-
stepDelayMs:
|
|
2475
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
2462
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2463
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2476
2464
|
});
|
|
2477
2465
|
await this.backend.mouseButton('left', 'doubleClick');
|
|
2478
2466
|
},
|
|
2479
2467
|
rightClick: async ({ x, y })=>{
|
|
2480
2468
|
await this.movePointer(Math.round(x), Math.round(y), {
|
|
2481
|
-
steps:
|
|
2482
|
-
stepDelayMs:
|
|
2483
|
-
settleDelayMs: desktopPointerPolicy.uiSettleMs
|
|
2469
|
+
steps: device_SMOOTH_MOVE_STEPS_TAP,
|
|
2470
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_TAP
|
|
2484
2471
|
});
|
|
2485
2472
|
await this.backend.mouseButton('right', 'click');
|
|
2486
2473
|
},
|
|
2487
2474
|
hover: async ({ x, y })=>{
|
|
2488
2475
|
await this.movePointer(Math.round(x), Math.round(y), {
|
|
2489
|
-
steps:
|
|
2490
|
-
stepDelayMs:
|
|
2491
|
-
settleDelayMs:
|
|
2476
|
+
steps: device_SMOOTH_MOVE_STEPS_MOUSE_MOVE,
|
|
2477
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_MOUSE_MOVE,
|
|
2478
|
+
settleDelayMs: device_MOUSE_MOVE_EFFECT_WAIT
|
|
2492
2479
|
});
|
|
2493
2480
|
},
|
|
2494
2481
|
dragAndDrop: async (from, to)=>{
|
|
@@ -2509,12 +2496,11 @@ class RDPDevice {
|
|
|
2509
2496
|
x: target.center[0],
|
|
2510
2497
|
y: target.center[1]
|
|
2511
2498
|
});
|
|
2512
|
-
await (0, utils_namespaceObject.sleep)(
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
}
|
|
2499
|
+
await (0, utils_namespaceObject.sleep)(device_INPUT_FOCUS_DELAY);
|
|
2500
|
+
}
|
|
2501
|
+
if (opts?.replace !== false) {
|
|
2502
|
+
await this.clearInput();
|
|
2503
|
+
await (0, utils_namespaceObject.sleep)(device_INPUT_CLEAR_DELAY);
|
|
2518
2504
|
}
|
|
2519
2505
|
if (opts?.focusOnly || !value) return;
|
|
2520
2506
|
await this.typeText(value, resolvedInputOptions);
|
|
@@ -2527,21 +2513,18 @@ class RDPDevice {
|
|
|
2527
2513
|
x: element.center[0],
|
|
2528
2514
|
y: element.center[1]
|
|
2529
2515
|
});
|
|
2530
|
-
await (0, utils_namespaceObject.sleep)(
|
|
2516
|
+
await (0, utils_namespaceObject.sleep)(device_INPUT_FOCUS_DELAY);
|
|
2531
2517
|
}
|
|
2532
2518
|
await this.clearInput();
|
|
2533
|
-
await (0, utils_namespaceObject.sleep)(
|
|
2519
|
+
await (0, utils_namespaceObject.sleep)(device_INPUT_CLEAR_DELAY);
|
|
2534
2520
|
},
|
|
2535
2521
|
keyboardPress: async (keyName, opts)=>{
|
|
2536
2522
|
this.assertConnected();
|
|
2537
2523
|
const target = opts?.target;
|
|
2538
|
-
if (target) {
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
});
|
|
2543
|
-
await (0, utils_namespaceObject.sleep)(desktopKeyboardPolicy.focusBeforeShortcutMs);
|
|
2544
|
-
}
|
|
2524
|
+
if (target) await this.inputPrimitives.pointer.tap({
|
|
2525
|
+
x: target.center[0],
|
|
2526
|
+
y: target.center[1]
|
|
2527
|
+
});
|
|
2545
2528
|
await this.backend.keyPress(keyName);
|
|
2546
2529
|
}
|
|
2547
2530
|
},
|
|
@@ -2549,27 +2532,17 @@ class RDPDevice {
|
|
|
2549
2532
|
scroll: async (param)=>{
|
|
2550
2533
|
this.assertConnected();
|
|
2551
2534
|
const target = param.locate;
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
const size = await this.size();
|
|
2556
|
-
scrollPoint = [
|
|
2557
|
-
Math.round(size.width / 2),
|
|
2558
|
-
Math.round(size.height / 2)
|
|
2559
|
-
];
|
|
2560
|
-
}
|
|
2561
|
-
await this.movePointer(Math.round(scrollPoint[0]), Math.round(scrollPoint[1]), {
|
|
2562
|
-
steps: desktopPointerPolicy.hoverMoveSteps,
|
|
2563
|
-
stepDelayMs: desktopPointerPolicy.hoverMoveStepDelayMs,
|
|
2564
|
-
settleDelayMs: target ? desktopPointerPolicy.moveSettleMs : desktopPointerPolicy.uiSettleMs
|
|
2535
|
+
if (target) await this.moveToElement(target, {
|
|
2536
|
+
steps: device_SMOOTH_MOVE_STEPS_MOUSE_MOVE,
|
|
2537
|
+
stepDelayMs: device_SMOOTH_MOVE_DELAY_MOUSE_MOVE
|
|
2565
2538
|
});
|
|
2566
2539
|
if (param.scrollType && 'singleAction' !== param.scrollType) {
|
|
2567
2540
|
const direction = this.edgeScrollDirection(param.scrollType);
|
|
2568
|
-
for(let i = 0; i < device_EDGE_SCROLL_STEPS; i++)await this.performWheel(direction, DEFAULT_SCROLL_DISTANCE,
|
|
2541
|
+
for(let i = 0; i < device_EDGE_SCROLL_STEPS; i++)await this.performWheel(direction, DEFAULT_SCROLL_DISTANCE, target?.center[0], target?.center[1]);
|
|
2569
2542
|
await (0, utils_namespaceObject.sleep)(device_SCROLL_COMPLETE_DELAY);
|
|
2570
2543
|
return;
|
|
2571
2544
|
}
|
|
2572
|
-
await this.performWheel(param.direction || 'down', param.distance || this.defaultScrollDistance(param.direction || 'down'),
|
|
2545
|
+
await this.performWheel(param.direction || 'down', param.distance || this.defaultScrollDistance(param.direction || 'down'), target?.center[0], target?.center[1]);
|
|
2573
2546
|
await (0, utils_namespaceObject.sleep)(device_SCROLL_COMPLETE_DELAY);
|
|
2574
2547
|
}
|
|
2575
2548
|
}
|
|
@@ -2850,7 +2823,7 @@ class ComputerMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
2850
2823
|
}
|
|
2851
2824
|
const env_namespaceObject = require("@midscene/shared/env");
|
|
2852
2825
|
function version() {
|
|
2853
|
-
const currentVersion = "1.
|
|
2826
|
+
const currentVersion = "1.14.0";
|
|
2854
2827
|
console.log(`@midscene/computer v${currentVersion}`);
|
|
2855
2828
|
return currentVersion;
|
|
2856
2829
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -384,6 +384,7 @@ export declare class RDPDevice implements AbstractInterface {
|
|
|
384
384
|
actionSpace(): DeviceAction<any>[];
|
|
385
385
|
private assertConnected;
|
|
386
386
|
private throwIfDestroyed;
|
|
387
|
+
private moveToElement;
|
|
387
388
|
private clearInput;
|
|
388
389
|
private edgeScrollDirection;
|
|
389
390
|
private defaultScrollDistance;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/computer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Midscene.js Computer Desktop Automation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@computer-use/libnut": "^4.2.0",
|
|
34
34
|
"clipboardy": "^4.0.0",
|
|
35
35
|
"screenshot-desktop": "^1.15.3",
|
|
36
|
-
"@midscene/core": "1.
|
|
37
|
-
"@midscene/shared": "1.
|
|
36
|
+
"@midscene/core": "1.14.0",
|
|
37
|
+
"@midscene/shared": "1.14.0"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
40
|
"node-mac-permissions": "2.5.0"
|