Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function simulateMouseMovementOnXCloud() {
- // Define start and end coordinates in viewport pixels
- const startX = window.innerWidth / 4;
- const startY = window.innerHeight / 4;
- const endX = window.innerWidth / 2;
- const endY = window.innerHeight / 2;
- console.log(`[XCloud Sim] Simulating mouse movement from viewport coordinates (${Math.round(startX)}, ${Math.round(startY)}) to (${Math.round(endX)}, ${Math.round(endY)})`);
- // 1. Simulate a pointermove to the starting position.
- // This helps establish an initial point, especially if absolute mouse mode is active.
- // The MouseManager's internal `lastAbsoluteX` and `lastAbsoluteY` might be updated.
- const initialMoveEvent = new PointerEvent('pointermove', {
- bubbles: true, // Should bubble up the DOM
- cancelable: true, // Can be canceled
- view: window, // The window context
- clientX: startX,
- clientY: startY,
- movementX: 0, // No movement relative to a "previous" point for this first event
- movementY: 0,
- pointerType: 'mouse', // Critical, as MouseManager checks e.pointerType === 'mouse'
- buttons: 0 // No mouse buttons pressed
- });
- window.dispatchEvent(initialMoveEvent);
- console.log("[XCloud Sim] Dispatched initial 'pointermove' to start position.");
- // 2. Simulate a pointermove to the ending position.
- // A small delay can sometimes help ensure the browser/page processes events sequentially.
- setTimeout(() => {
- const moveEvent = new PointerEvent('pointermove', {
- bubbles: true,
- cancelable: true,
- view: window,
- clientX: endX,
- clientY: endY,
- movementX: endX - startX, // Relative movement from the startX
- movementY: endY - startY, // Relative movement from the startY
- pointerType: 'mouse',
- buttons: 0 // No mouse buttons pressed
- });
- window.dispatchEvent(moveEvent);
- console.log("[XCloud Sim] Dispatched 'pointermove' to end position.");
- console.log("[XCloud Sim] Mouse movement simulation attempt complete.");
- }, 100); // 100ms delay before the main move
- }
- console.log("[XCloud Sim] Script loaded. Waiting 5 seconds to simulate mouse movement...");
- setTimeout(simulateMouseMovementOnXCloud, 5000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement