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

158 lines
5.1 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 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 - 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
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"Add-Type -TypeDefinition @' " ^
"using System; " ^
"using System.Runtime.InteropServices; " ^
"public class MouseMover { " ^
" [DllImport(\"user32.dll\")] " ^
" public static extern bool GetCursorPos(out POINT lpPoint); " ^
" [DllImport(\"user32.dll\")] " ^
" public static extern uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize); " ^
" [StructLayout(LayoutKind.Sequential)] " ^
" public struct INPUT { " ^
" public uint type; " ^
" public MOUSEINPUT mi; " ^
" } " ^
" [StructLayout(LayoutKind.Sequential)] " ^
" public struct MOUSEINPUT { " ^
" public int dx; " ^
" public int dy; " ^
" public uint mouseData; " ^
" public uint dwFlags; " ^
" public uint time; " ^
" public IntPtr dwExtraInfo; " ^
" } " ^
" public struct POINT { " ^
" public int X; " ^
" public int Y; " ^
" } " ^
" public const uint INPUT_MOUSE = 0; " ^
" public const uint MOUSEEVENTF_MOVE = 0x0001; " ^
"} " ^
"'@; " ^
"$interval = %INTERVAL%; " ^
"$durationMinutes = %DURATION_MINUTES%; " ^
"$random = New-Object System.Random; " ^
"$startTime = Get-Date; " ^
"$moveCount = 0; " ^
"Write-Host ''; " ^
"Write-Host '========================================' -ForegroundColor Green; " ^
"Write-Host 'Mouse Mover Active (Hardware Simulation)' -ForegroundColor Green; " ^
"Write-Host '========================================' -ForegroundColor Green; " ^
"Write-Host ''; " ^
"Write-Host 'Monitoring mouse movement...'; " ^
"Write-Host 'Press Ctrl+C to stop'; " ^
"Write-Host ''; " ^
"$lastPos = New-Object MouseMover+POINT; " ^
"[void][MouseMover]::GetCursorPos([ref]$lastPos); " ^
"while ($true) { " ^
" if ($durationMinutes -gt 0) { " ^
" $elapsed = ((Get-Date) - $startTime).TotalMinutes; " ^
" if ($elapsed -ge $durationMinutes) { " ^
" Write-Host ''; " ^
" Write-Host 'Duration reached. Stopping...' -ForegroundColor Yellow; " ^
" break; " ^
" } " ^
" } " ^
" $currentPos = New-Object MouseMover+POINT; " ^
" [void][MouseMover]::GetCursorPos([ref]$currentPos); " ^
" if ($currentPos.X -ne $lastPos.X -or $currentPos.Y -ne $lastPos.Y) { " ^
" $lastPos = $currentPos; " ^
" $time = Get-Date -Format 'HH:mm:ss'; " ^
" Write-Host \"[$time] User moved mouse - Paused\" -ForegroundColor Cyan; " ^
" Start-Sleep -Seconds $interval; " ^
" continue; " ^
" } " ^
" $moveX = $random.Next(-5, 6); " ^
" $moveY = $random.Next(-5, 6); " ^
" $input = New-Object MouseMover+INPUT; " ^
" $input.type = [MouseMover]::INPUT_MOUSE; " ^
" $input.mi.dx = $moveX; " ^
" $input.mi.dy = $moveY; " ^
" $input.mi.dwFlags = [MouseMover]::MOUSEEVENTF_MOVE; " ^
" $input.mi.time = 0; " ^
" $input.mi.dwExtraInfo = [IntPtr]::Zero; " ^
" $inputs = @($input); " ^
" [void][MouseMover]::SendInput(1, $inputs, [System.Runtime.InteropServices.Marshal]::SizeOf($input)); " ^
" $moveCount++; " ^
" $time = Get-Date -Format 'HH:mm:ss'; " ^
" Write-Host \"[$time] Auto-moved mouse ($moveCount moves)\" -ForegroundColor Green; " ^
" [void][MouseMover]::GetCursorPos([ref]$lastPos); " ^
" Start-Sleep -Seconds $interval; " ^
"} " ^
"Write-Host ''; " ^
"Write-Host '========================================' -ForegroundColor Yellow; " ^
"Write-Host 'Mouse Mover Stopped' -ForegroundColor Yellow; " ^
"Write-Host \"Total moves: $moveCount\" -ForegroundColor Yellow; " ^
"Write-Host '========================================' -ForegroundColor Yellow;"
echo.
echo ========================================
echo Script finished
echo ========================================
pause