设置两分钟的时间间隔(以秒为单位)
$interval = 120
while ($true) {
# 创建对象,模拟鼠标移动
$signature = @"
[System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”) | Out-Null
$signature = @"
[System.Runtime.InteropServices.DllImport(“user32.dll”, SetLastError = true)]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool SetCursorPos(int x, int y);
"@
Add-Type -MemberDefinition $signature -Namespace Win32Functions -Name SetCursorPos
[Win32Functions.SetCursorPos]::SetCursorPos([System.Windows.Forms.Cursor]::Position.X + 1, [System.Windows.Forms.Cursor]::Position.Y + 1)
"@
# 等待两分钟
Start-Sleep -Seconds $interval
}
.\MoveMouse.ps1
Set-ExecutionPolicy RemoteSigned