$WShell = New-Object -com "Wscript.Shell"
while($true)
{
$WShell.sendkeys("{SCROLLLOCK}")
$WShell.sendkeys("{SCROLLLOCK}")
$date = Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss"
Write-Host $date + " No sleep with scroll lock"
Start-Sleep -Seconds 100
}
Add-Type -AssemblyName System.Windows.Forms
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class MouseClicker {
[DllImport("user32.dll", CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
public const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;
public const int MOUSEEVENTF_MIDDLEUP = 0x0040;
}
"@
$WShell = New-Object -com "Wscript.Shell"
while ($true)
{
$pos = [System.Windows.Forms.Cursor]::Position
for ($i = 0; $i -le 200; $i += 5) {
$newPos = [System.Drawing.Point]::new($pos.X + $i, $pos.Y)
[System.Windows.Forms.Cursor]::Position = $newPos
#Start-Sleep -Milliseconds 10
}
for ($i = 200; $i -ge 0; $i -= 5) {
$newPos = [System.Drawing.Point]::new($pos.X + $i, $pos.Y)
[System.Windows.Forms.Cursor]::Position = $newPos
#Start-Sleep -Milliseconds 10
}
[MouseClicker]::mouse_event([MouseClicker]::MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
Start-Sleep -Milliseconds 100
[MouseClicker]::mouse_event([MouseClicker]::MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
$WShell.sendkeys("{SCROLLLOCK}")
$WShell.sendkeys("{SCROLLLOCK}")
$date = Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss"
Write-Host $date + " No sleep with scroll lock"
Start-Sleep -Milliseconds 120000
}