找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 19549|回复: 3

[文件操作] 请教WIN10下能用的批处理系统空闲时间监测

[复制链接]
发表于 2021-12-22 19:53:28 | 显示全部楼层 |阅读模式
在WIN10 下 鼠标键盘多久时间没动 就执行程序,比如说自动关机。
论坛里面搜出来的几个WIN10 下好像都不能执行。
发表于 2021-12-22 21:31:34 | 显示全部楼层
回复 1# conan2095


    你搜到的是哪几个?我试试能否修改成Win10能用的。
 楼主| 发表于 2021-12-22 21:44:33 | 显示全部楼层
回复 2# Batcher


    http://www.bathome.net/thread-20370-1-1.html

大哥是这个帖子
发表于 2021-12-23 16:25:56 | 显示全部楼层
  1. #@&cls&powershell "type %~s0|out-string|iex"&pause&exit
  2. Add-Type @'
  3. using System;
  4. using System.Runtime.InteropServices;
  5. public static class GetIdleTime {
  6.     [DllImport("user32.dll")]
  7.     public static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
  8.     [StructLayout(LayoutKind.Sequential)]
  9.     public struct LASTINPUTINFO {
  10.         public int cbSize;
  11.         public uint dwTime;
  12.     }
  13.     public static long IdleTime{
  14.         get {
  15.             LASTINPUTINFO lii = new LASTINPUTINFO();
  16.             lii.cbSize = Marshal.SizeOf(lii);
  17.             if (!GetLastInputInfo(ref lii)) return 0;
  18.             return Environment.TickCount - (uint)lii.dwTime;
  19.         }
  20.     }
  21. }
  22. '@
  23. while(!(sleep 1)){
  24.     if([getidletime]::IdleTime/1000 -gt 3){"空闲时间大于3秒"}
  25. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-20 19:32 , Processed in 0.029987 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表