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