Files
HyperCLI/files/automatic-mouse-mover.bat

214 lines
6.2 KiB
Batchfile

@echo off
REM === Automatic Mouse Mover ===
setlocal enabledelayedexpansion
echo ========================================
echo Automatic Mouse Mover
echo ========================================
echo.
echo This script will move your mouse cursor slightly
echo to prevent screen lock or idle status.
echo.
echo ========================================
echo.
REM Get interval
:GET_INTERVAL
set /p INTERVAL="Enter interval in seconds (3-10): "
REM Validate interval
if %INTERVAL% LSS 3 (
echo Invalid! Minimum is 3 seconds.
goto GET_INTERVAL
)
if %INTERVAL% GTR 10 (
echo Invalid! Maximum is 10 seconds.
goto GET_INTERVAL
)
echo.
REM Get cursor movement option
echo Cursor movement:
echo [1] Visible cursor movement
echo [2] Invisible (cursor stays in place)
echo.
set /p CURSOR_CHOICE="Select option (1-2): "
if "%CURSOR_CHOICE%"=="1" (
set CURSOR_MOVE=true
set CURSOR_TEXT=Visible movement
) else if "%CURSOR_CHOICE%"=="2" (
set CURSOR_MOVE=false
set CURSOR_TEXT=Invisible
) else (
echo Invalid selection!
timeout /t 2 >nul
goto GET_INTERVAL
)
echo.
REM Get duration
echo Duration options:
echo [1] Continuous (press Ctrl+C to stop)
echo [2] Specific duration in minutes
echo.
set /p DURATION_CHOICE="Select option (1-2): "
if "%DURATION_CHOICE%"=="1" (
set DURATION_MINUTES=0
set DURATION_TEXT=Continuous
) else if "%DURATION_CHOICE%"=="2" (
set /p DURATION_MINUTES="Enter duration in minutes: "
set DURATION_TEXT=!DURATION_MINUTES! minutes
) else (
echo Invalid selection!
timeout /t 2 >nul
goto GET_INTERVAL
)
echo.
echo ========================================
echo Configuration:
echo - Interval: %INTERVAL% seconds
echo - Duration: %DURATION_TEXT%
echo - Cursor: %CURSOR_TEXT%
echo - Movement: Random 1-5 pixels
echo - Auto-pause when you move the mouse
echo ========================================
echo.
echo Press Ctrl+C to stop at any time.
echo.
pause
cls
echo Starting Mouse Mover...
echo.
REM Create PowerShell script with proper escaping
(
echo Add-Type -TypeDefinition @"
echo using System;
echo using System.Runtime.InteropServices;
echo public class MouseMover {
echo [DllImport^("user32.dll"^)]
echo public static extern bool GetCursorPos^(out POINT lpPoint^);
echo.
echo [DllImport^("user32.dll"^)]
echo public static extern bool SetCursorPos^(int x, int y^);
echo.
echo [DllImport^("user32.dll"^)]
echo public static extern uint SendInput^(uint nInputs, INPUT[] pInputs, int cbSize^);
echo.
echo [StructLayout^(LayoutKind.Sequential^)]
echo public struct INPUT {
echo public uint type;
echo public MOUSEINPUT mi;
echo }
echo.
echo [StructLayout^(LayoutKind.Sequential^)]
echo public struct MOUSEINPUT {
echo public int dx;
echo public int dy;
echo public uint mouseData;
echo public uint dwFlags;
echo public uint time;
echo public IntPtr dwExtraInfo;
echo }
echo.
echo public struct POINT {
echo public int X;
echo public int Y;
echo }
echo.
echo public const uint INPUT_MOUSE = 0;
echo public const uint MOUSEEVENTF_MOVE = 0x0001;
echo }
echo "@
echo.
echo $interval = %INTERVAL%
echo $durationMinutes = %DURATION_MINUTES%
echo $cursorMove = $%CURSOR_MOVE%
echo $random = New-Object System.Random
echo $startTime = Get-Date
echo $moveCount = 0
echo.
echo Write-Host ""
echo Write-Host "========================================" -ForegroundColor Green
echo Write-Host "Mouse Mover Active (Hardware Simulation)" -ForegroundColor Green
echo Write-Host "========================================" -ForegroundColor Green
echo Write-Host ""
echo Write-Host "Monitoring mouse movement..."
echo Write-Host "Press Ctrl+C to stop"
echo Write-Host ""
echo.
echo $lastPos = New-Object MouseMover+POINT
echo [void][MouseMover]::GetCursorPos^([ref]$lastPos^)
echo.
echo while ^($true^) {
echo if ^($durationMinutes -gt 0^) {
echo $elapsed = ^(^(Get-Date^) - $startTime^).TotalMinutes
echo if ^($elapsed -ge $durationMinutes^) {
echo Write-Host ""
echo Write-Host "Duration reached. Stopping..." -ForegroundColor Yellow
echo break
echo }
echo }
echo.
echo $currentPos = New-Object MouseMover+POINT
echo [void][MouseMover]::GetCursorPos^([ref]$currentPos^)
echo.
echo if ^($currentPos.X -ne $lastPos.X -or $currentPos.Y -ne $lastPos.Y^) {
echo $lastPos = $currentPos
echo $time = Get-Date -Format 'HH:mm:ss'
echo Write-Host "[$time] User moved mouse - Paused" -ForegroundColor Cyan
echo Start-Sleep -Seconds $interval
echo continue
echo }
echo.
echo $moveX = $random.Next^(-5, 6^)
echo $moveY = $random.Next^(-5, 6^)
echo.
echo $input = New-Object MouseMover+INPUT
echo $input.type = [MouseMover]::INPUT_MOUSE
echo $input.mi.dx = $moveX
echo $input.mi.dy = $moveY
echo $input.mi.dwFlags = [MouseMover]::MOUSEEVENTF_MOVE
echo $input.mi.time = 0
echo $input.mi.dwExtraInfo = [IntPtr]::Zero
echo.
echo $inputs = @^($input^)
echo [void][MouseMover]::SendInput^(1, $inputs, [System.Runtime.InteropServices.Marshal]::SizeOf^($input^)^)
echo.
echo if ^($cursorMove^) {
echo $newX = $currentPos.X + $moveX
echo $newY = $currentPos.Y + $moveY
echo [void][MouseMover]::SetCursorPos^($newX, $newY^)
echo }
echo $moveCount++
echo.
echo $time = Get-Date -Format 'HH:mm:ss'
echo Write-Host "[$time] Auto-moved mouse ($moveCount moves)" -ForegroundColor Green
echo.
echo [void][MouseMover]::GetCursorPos^([ref]$lastPos^)
echo.
echo Start-Sleep -Seconds $interval
echo }
echo.
echo Write-Host ""
echo Write-Host "========================================" -ForegroundColor Yellow
echo Write-Host "Mouse Mover Stopped" -ForegroundColor Yellow
echo Write-Host "Total moves: $moveCount" -ForegroundColor Yellow
echo Write-Host "========================================" -ForegroundColor Yellow
) > "%TEMP%\MouseMover.ps1"
REM Execute PowerShell script
powershell -NoProfile -ExecutionPolicy Bypass -File "%TEMP%\MouseMover.ps1"
REM Cleanup
del "%TEMP%\MouseMover.ps1" >nul 2>&1
echo.
echo ========================================
echo Script finished
echo ========================================
pause