返回列表 发帖
回复 8# pcl_test


    也好……忘了有Start这码事情了
话说斑竹你能不能不要学这么快……我刚开始学批你在学VBS……我学了VBS你在学PS……VBS学了没多久又 玩C#
酱紫让人压力山大啊……

TOP

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

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

TOP

回复 5# pcl_test


    有个缺点,锁定的时候CMD需要需要干其他的事情啊……
总不能就一直等着吧……

TOP

回复 5# pcl_test


    也是最近发现User32里面有个API……
User32.dll真是一个神奇的东东

TOP

本帖最后由 pcl_test 于 2017-3-30 12:35 编辑
/*&cls
@echo off
set "netpath=%systemroot%\Microsoft.NET\Framework"
for /f "delims=" %%a in ('dir /ad /b "%netpath%\v?.*"') do (
    if exist "%netpath%\%%a\csc.exe" (
        set "cscpath=%netpath%\%%a\csc.exe"
        goto :0
    )
)
echo;未安装.Net Framework 2.0及其上版本组件或相关程序丢失&pause&exit/b
:0
"%cscpath%" /out:"$BlockInput.exe" "%~f0"
"$BlockInput.exe"
pause&exit
*/
using System;
using System.Threading;
using System.Runtime.InteropServices;
class BlockUserInput
{
    [DllImport("user32.dll")]
    static extern bool BlockInput(bool BlockIt);
    static void Main(string[] args)
    {
        if(args.Length<1){
            Console.WriteLine("Blocks keyboard and mouse input events.\r\n"+
                "Usage:\r\n$BlockInput.exe seconds  //The valid range is 0 ~ 86400.");
            Thread.Sleep(2000);
        }else{
            try{
                int num = Convert.ToInt32(args[0].ToString());
                if(num>=0 && num<=86400){
                    Console.WriteLine("Blocking...");
                    BlockInput(true);
                    Thread.Sleep(num*1000);
                }else Console.WriteLine("Input out of range.");
            }catch{Console.WriteLine("Enter an integer between 0 and 86400.");}
        }
    }
}COPY
1

评分人数

TOP

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

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

TOP

已收录到 Batch-CN
1

评分人数

TOP

听说联系Crlf斑竹可以放第三方库~
回复 1# CrLf
回复 2# CrLf
回复 3# CrLf
回复 4# CrLf
回复 5# CrLf
回复 CrLf
回复 CrLf
回复 CrLf
回复 Cr CrLf
回复 lf CrLf

TOP

返回列表