復制粘貼到記事本,另存為xx.bat,編碼選ANSI<# :
cls
@echo off
rem 整點自動截屏
mode con cols=40 lines=8
if "%~1" equ "" (
start /min "" "%~f0" fk
exit
)
cd /d "%~dp0"
powershell -sta -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default)))"
pause
exit
#>
#截屏圖片存放的目錄
$folder="C:\ScreenShot";
if(-not (test-path -liter $folder)){[void](md $folder)};
$codes=@'
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
public static class ScreenShot{
public static void Save(string f){
Image img=new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
Graphics g=Graphics.FromImage(img);
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.AllScreens[0].Bounds.Size);
img.Save(f, ImageFormat.Bmp);
}
}
'@;
Add-Type -TypeDefinition $codes -ReferencedAssemblies 'System.Windows.Forms','System.Drawing';
$n=0;while($true){
cls
$now=(get-date).toString('yyyy-MM-dd HH:mm:ss');
write-host 'Keep this window minimized';
write-host 'Do not close this window';
write-host $n.toString();write-host $now;
$m=[regex]::match($now, '00:0[0-9]$');
if($m.Success){
$newfile=$folder.trimend('\')+'\'+($now -replace '[-\s:]|\d\d$','')+'00.bmp';
if(-not (test-path -liter $newfile)){$n++;[ScreenShot]::Save($newfile);};
};
start-sleep -Seconds 1;
}