[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 16# 老刘1号

试试能否不借助临时文件

TOP

本帖最后由 pcl_test 于 2017-3-30 12:57 编辑

回复 6# 老刘1号
ahk的BlockInput底层调用的就是这个API
回复 7# 老刘1号
第三方的特定之一就是可以独立运行,start即可

TOP

本帖最后由 pcl_test 于 2017-3-30 12:35 编辑
  1. /*&cls
  2. @echo off
  3. set "netpath=%systemroot%\Microsoft.NET\Framework"
  4. for /f "delims=" %%a in ('dir /ad /b "%netpath%\v?.*"') do (
  5.     if exist "%netpath%\%%a\csc.exe" (
  6.         set "cscpath=%netpath%\%%a\csc.exe"
  7.         goto :0
  8.     )
  9. )
  10. echo;未安装.Net Framework 2.0及其上版本组件或相关程序丢失&pause&exit/b
  11. :0
  12. "%cscpath%" /out:"$BlockInput.exe" "%~f0"
  13. "$BlockInput.exe"
  14. pause&exit
  15. */
  16. using System;
  17. using System.Threading;
  18. using System.Runtime.InteropServices;
  19. class BlockUserInput
  20. {
  21.     [DllImport("user32.dll")]
  22.     static extern bool BlockInput(bool BlockIt);
  23.     static void Main(string[] args)
  24.     {
  25.         if(args.Length<1){
  26.             Console.WriteLine("Blocks keyboard and mouse input events.\r\n"+
  27.                 "Usage:\r\n$BlockInput.exe seconds  //The valid range is 0 ~ 86400.");
  28.             Thread.Sleep(2000);
  29.         }else{
  30.             try{
  31.                 int num = Convert.ToInt32(args[0].ToString());
  32.                 if(num>=0 && num<=86400){
  33.                     Console.WriteLine("Blocking...");
  34.                     BlockInput(true);
  35.                     Thread.Sleep(num*1000);
  36.                 }else Console.WriteLine("Input out of range.");
  37.             }catch{Console.WriteLine("Enter an integer between 0 and 86400.");}
  38.         }
  39.     }
  40. }
复制代码
1

评分人数

TOP

本帖最后由 pcl_test 于 2017-3-30 12:40 编辑

看了下大小,很大,发现原来是ahk封装的
  1. #NoEnv
  2. #NoTrayIcon
  3. if A_OSVersion in WIN_8,WIN_8.1
  4. {
  5. MsgBox ,,提示,暂不支持Win8及以上系统,10
  6. ExitApp
  7. }
  8. Else
  9. {
  10. BlockInput,On   ;由于 Windows API 的特性,按下 Ctrl+Alt+Del 将重新启用输入
  11. sleep,%1%000
  12. BlockInput,Off
  13. }
复制代码

TOP

返回列表