Code: Select all
@echo off
setlocal enabledelayedexpansion
call :make "%~f0"
for /L %%a in () do (
neoGetKey.exe 500 x
set "err=!errorlevel!"
if !err! equ 255 (echo; time out) else echo; pressed key value is : !err!
)
exit
:make
for /f "delims=:" %%a in ('findstr /n /i "^:BEGIN:getKEY.B64" "%~1"') do set "sk=%%a"
> getKEY.B64 cd.
for /f "useback skip=%sk% delims=" %%f in ("%~1") do (
if /i not "%%f"==":END:getKEY.B64" (>> getKEY.B64 echo;%%f) else (
certutil -f -decode getKEY.B64 neoGetKey.exe
exit /b
)
)
)
exit /b
neoGetKey.exe
aa77dd@163.com @ 20160907_122038
获取当前被按下的 按键 值, 支持全键盘按键, 以及鼠标 左 右 中键
参数说明:
neoGetKey.exe timeout showMethod
timeout 超时数, 单位 ms, 在运行超过此时间后自动退出, 并返回 255
如果 此项是 0 将一直等到检测到有键按下, 程序才会结束并返回键值.
如果 此项不存在, 最长将等到默认值 1000ms 后退出
showMethod 返回值的显示方式, 此项为 D 以十进制显示, 此项为 X 以十六进制显示
如果此项不存在, 将不会显示返回值
::BEGIN:neoGetKey.C
#include <Windows.h>
#include <stdio.h>
int main(int argc, char** argv) {
int i, t = 1000;
char show = '\0';
if (argc >= 2) t = atoi(argv[1]);
if (argc >= 3) {
show = (**(argv + 2) == 'x' || **(argv + 2) == 'X') ? 'x' : (**(argv + 2) == 'd' || **(argv + 2) == 'D') ? 'd' : '\0';
}
for (i = 0; t == 0 || i < t; i++) {
int x;
for (x = 1; x <= 254; x++)
if (GetAsyncKeyState(x) & 0x8000) {
if (show == 'x') printf("%x", x);
if (show == 'd') printf("%d", x);
return x;
}
sleep(1);
}
if (show == 'x') printf("%x", 255);
if (show == 'd') printf("%d", 255);
return 255;
}
::END:neoGetKey.C
:BEGIN:getKEY.B64
-----BEGIN CERTIFICATE-----
TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAgAAAAA4fug4A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