Board logo

标题: [其他] [20170624更新]键鼠锁定工具-BlockUserInput [打印本页]

作者: 老刘1号    时间: 2017-3-9 19:32     标题: [20170624更新]键鼠锁定工具-BlockUserInput

http://bcn.bathome.net/s/tool/index.html?key=BlockUserInput
为了防止有些熊孩子在脚本运行时胡乱操作,故写出分享

2017.6.24更新了版本,使用NET2.0重新编译,增强了兼容性

2017.6.3更新了版本,对PCL斑竹的C#源代码做了略微修改,体积精简到3KB,压缩后不足1.2KB。用法更为简便,直接Start即可。
如果不使用Taskkill结束,将会在一天后自动关闭

2017.5.2更新了版本,可以随时控制开关,无需计时控制,更加灵活


Ctrl+Alt+Delete可以开启输入(别告诉使用者就行)
SRC如下(修改自PCL斑竹的C#代码)
  1. using System;
  2. using System.Threading;
  3. using System.Runtime.InteropServices;
  4. class BlockUserInput
  5. {
  6. [DllImport("user32.dll")]
  7. static extern bool BlockInput(bool BlockIt);
  8. static void Main(string[] args)
  9. {
  10. BlockInput(true);
  11. Thread.Sleep(24*60*60*1000);
  12. }
  13. }
复制代码
此外,可以与Nircmdc的SendkeypressClick搭配食用,实现无干扰的键鼠系统操作。
用法&示例:
  1. START /min BlockUserInput
  2. PING Baidu.cn -n 10
  3. Taskkill /f /im BlockUserInput.exe
复制代码

作者: 老刘1号    时间: 2017-3-10 22:27

听说联系Crlf斑竹可以放第三方库~
回复 1# CrLf
回复 2# CrLf
回复 3# CrLf
回复 4# CrLf
回复 5# CrLf
回复 CrLf
回复 CrLf
回复 CrLf
回复 Cr CrLf
回复 lf CrLf
作者: CrLf    时间: 2017-3-30 02:20

已收录到 Batch-CN
作者: pcl_test    时间: 2017-3-30 12:31

本帖最后由 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. }
复制代码

作者: pcl_test    时间: 2017-3-30 12:32

本帖最后由 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号    时间: 2017-3-30 12:45

回复 5# pcl_test


    也是最近发现User32里面有个API……
User32.dll真是一个神奇的东东
作者: 老刘1号    时间: 2017-3-30 12:51

回复 5# pcl_test


    有个缺点,锁定的时候CMD需要需要干其他的事情啊……
总不能就一直等着吧……
作者: pcl_test    时间: 2017-3-30 12:53

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

回复 6# 老刘1号
ahk的BlockInput底层调用的就是这个API
回复 7# 老刘1号
第三方的特定之一就是可以独立运行,start即可
作者: 老刘1号    时间: 2017-3-30 13:00

回复 8# pcl_test


    也好……忘了有Start这码事情了
话说斑竹你能不能不要学这么快……我刚开始学批你在学VBS……我学了VBS你在学PS……VBS学了没多久又 玩C#
酱紫让人压力山大啊……
作者: CrLf    时间: 2017-3-30 15:52

最近还有没有什么第三方是未收录的?
作者: dingcool    时间: 2017-3-30 22:08

用个au3解决问题 blockinput
作者: Nsqs    时间: 2017-3-30 23:03

回复 10# CrLf


    不知道有没有重复,如有雷同纯属巧合,12年做的小玩意
作者: CrLf    时间: 2017-3-31 10:20

回复 12# Nsqs


    感谢自荐,回头看看
作者: Nsqs    时间: 2017-3-31 15:54

第一个附件说明写错了,应该是光标的坐标XY
作者: CrLf    时间: 2017-4-7 01:13

回复 12# Nsqs


    已收录,但 Tray 无法使用,请注明参数格式
    Sleep 的同名同类工具比较多,所以就偷个懒不收录了...
作者: 老刘1号    时间: 2017-5-2 13:15

回复 15# CrLf


    Crlf斑竹,版本更新了
以前的其实可以删了,挺占空间的
一封装起来就这么大了,见谅(x64版可以不收录)
作者: pcl_test    时间: 2017-5-2 23:25

回复 16# 老刘1号

试试能否不借助临时文件
作者: 老刘1号    时间: 2017-5-4 20:56

本帖最后由 老刘1号 于 2017-5-4 20:59 编辑

回复 17# pcl_test


    New version~
Input “ON” to run the locker,
Anything else can STOP the Script.
  1. #NoEnv
  2. #NoTrayIcon
  3. #SingleInstance FORCE
  4. StringUpper,参数1,1
  5. ifEqual,参数1,ON
  6. {
  7.     BlockInput,On
  8.     While 0 = 0
  9.         {}
  10. }
复制代码

作者: happy886rr    时间: 2017-5-4 22:58

  1. #include <stdio.h>
  2. #include <windows.h>
  3. BOOL WINAPI BlockInput(BOOL fBlockIt);
  4. int main(int argc, char** argv)
  5. {
  6. return (argc==1)?1:BlockInput(!stricmp(argv[1], "on"));
  7. }
复制代码

作者: 老刘1号    时间: 2017-6-3 21:56

回复 15# CrLf


    于是我又贱贱的更新了~
作者: 老刘1号    时间: 2017-6-4 22:22



测试下bbaa兄的黑科技
作者: qqqkoko123    时间: 2017-6-25 18:58

64位win7下鼠标正常使用,不管用啊。。。
作者: 老刘1号    时间: 2017-6-28 11:50

回复 22# qqqkoko123


    这个函数貌似在你的系统里被阉割了~




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2