初始化bat文件
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
# get_idle_minutes.ps1
|
||||
Add-Type @"
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class User32 {
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct LASTINPUTINFO {
|
||||
public uint cbSize;
|
||||
public uint dwTime;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
|
||||
}
|
||||
"@
|
||||
|
||||
$lii = New-Object User32+LASTINPUTINFO
|
||||
$lii.cbSize = [System.Runtime.InteropServices.Marshal]::SizeOf($lii)
|
||||
[User32]::GetLastInputInfo([ref]$lii)
|
||||
|
||||
$tickCount = [Environment]::TickCount
|
||||
$idleTicks = $tickCount - $lii.dwTime
|
||||
if ($idleTicks -lt 0) { $idleTicks += 0x100000000 }
|
||||
|
||||
$idleMinutes = [Math]::Floor($idleTicks / 1000 / 60)
|
||||
Write-Output $idleMinutes
|
||||
Reference in New Issue
Block a user