求每个整点电脑自动截屏并保存图像的bat或小程序
发布网友
发布时间:2022-04-21 06:03
我来回答
共2个回答
热心网友
时间:2022-06-18 09:27
复制粘贴到记事本,另存为xx.bat,编码选ANSI<# :
cls
@echo off
rem 整点自动截屏
mode con cols=55 lines=10
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
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;
}
热心网友
时间:2022-06-18 09:27
曾经写过一个整点截屏的bat脚本,不过运行后,仅在当天有效。因此到第二天,需要重新运行一次脚本。不知道您要不要?当然如果要每天都能定时截屏的。就得更改脚本中的相关代码了。追问要的要的 谢谢大佬,
追答前往这个问题中下载附件。
https://zhidao.baidu.com/question/1515575716199249700.html