try { # Add the System.Windows.Forms assembly to be able to interact with the screen and cursor Add-Type -AssemblyName System.Windows.Forms # Get the primary screen's resolution $ScreenWidth = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width $ScreenHeight = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height # Start an infinite loop while ($true) { # Generate random X and Y coordinates within the screen boundaries $RandomX = Get-Random -Minimum 0 -Maximum $ScreenWidth $RandomY = Get-Random -Minimum 0 -Maximum $ScreenHeight # Create a new Point object with the random coordinates $NewPosition = New-Object System.Drawing.Point($RandomX, $RandomY) # Set the cursor position to the new random point [System.Windows.Forms.Cursor]::Position = $NewPosition # Wait for 5 seconds Start-Sleep -Seconds 0.1 } } catch { Write-Host "An error occurred: $_" }