[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 13# cmd1152
在延时的时间要不断检查按键,所以不是单纯的Sleep。
/W 毫秒
/s  毫秒
功能,可以不同需求使用。

/g time
可以很好的控制进程的节奏。
已经有了思路,准备重写俄罗斯方块:提速+只显示一个窗口。


命令行直接输入出现空行的BUG,有空找一下原因在哪。谢谢测试。

TOP

14楼发现的Bug已经处理好。
  1. @echo off&setlocal enabledelayedexpansion
  2. rem 解压并转码
  3. if not exist mk.exe (
  4. setlocal enabledelayedexpansion
  5. for /l %%a in (1,1,100) do set /a n+=1&set t=!t!A&set A!n!=!t!
  6. (
  7. for /f "tokens=*" %%a in ('type "%~dpf0"') do (
  8. if "%%a" equ "-----BEGIN CERTIFICATE-----" set a=开始
  9. if defined a echo;%%a
  10. )
  11. )>mk.exe
  12. Certutil -Decode -f "mk.exe" "mk.exe" > nul
  13. endlocal
  14. )
  15. title   mk.exe 测试,按【ESC】退出!
  16. :loop
  17. set key=【无】
  18. for /f "tokens=1-5" %%1 in ('mk.exe /s 50') do (
  19. rem echo;%%1 %%2 %%3 %%4 %%5
  20. set str=无当前无按键
  21. IF "%%1" equ "2" (
  22. set str=鼠标
  23. if "%%5" equ "1" (set str=移动!str!)
  24. if "%%5" equ "2" (set str=双击!str!)
  25. if "%%5" equ "0" (
  26. if "%%4" equ "0" (set str=松开!str!)
  27. if "%%4" equ "1" (set str=按下!str!左键)
  28. if "%%4" equ "2" (set str=按下!str!右键)
  29. if "%%4" equ "4" (set str=按下!str!中键)
  30. )
  31. if "%%5" equ "4" if %%4 gtr 0 (set str=向上滚动!str!) else (set str=向下滚动!str!)
  32. set str=!str!,坐标:%%3行,%%2列
  33. ) else (
  34. set str=键盘
  35. if "%%4" equ "1" (set str=按下!str!) else (set str=松开!str!)
  36. if "%%2" equ "0" (set str=!str!扫描码是:%%3,状态码是:%%5) else (set str=!str!ASCII码是:%%2,状态码是:%%5&set key=%%2)
  37. )
  38. echo;!str!
  39. )
  40. echo;按键是%key%
  41. if "%key%" neq "27" goto :loop
  42. echo;测试结束,按任意键或者等待【5秒】后自动退出。
  43. mk /w 100 >nul
  44. mk /w 5000 >nul
  45. goto :eof
  46. -----BEGIN CERTIFICATE-----
  47. TVqQAAMAAAAEAAAA//8AALg!A9!Q!A31!
  48. !A16!u!A5!4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5v
  49. dCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJ!A10!Z2aFVXbjPBl24zwZduM8G
  50. 06fcBk+4zwahmN0GX7jPBlJpY2hduM8G!A21!FBFAABMAQMA
  51. fmC7YQ!A10!4AAPAQsBBQwABgAAACQ!A7!DCEAAAAB!A5!g!A5!EAA
  52. AB!A5!CAAAE!A10!Q!A10!G!A5!E!A9!w!A6!EAAAEAAA
  53. AAAQAAAQ!A8!E!A15!PCAAADw!A25!
  54. !A64!
  55. !A23!gAAA8!A36!
  56. LnRleHQAAAAcBQAAAB!A5!GAAAAB!A19!IAAAYC5yZGF0YQAA
  57. kgEAAAAg!A5!gAAAAo!A18!EAAAEAuZGF0YQAAAOghAAAAMAAA
  58. AAIAAAAM!A18!BAAAD!A33!
  59. !A64!
  60. !A64!
  61. !A64!
  62. !A64!
  63. !A64!
  64. !A64!
  65. !A64!
  66. !A64!
  67. !A64!
  68. !A21!FWL7IPE/GDHRfw!A5!6GUEAACL8PysCsB0IDwgdPdO
  69. /0X8rArAdBM8IHTqPCJ186wKwHQGPCJ19+voYYtF/MnDVYvsg8T4YP9FCMdF/AAA
  70. AACLfQzoHgQAAIvw/KwKwHRYPCB0907/RfzHRfg!A5!i0UIO0X8dQfHRfgBAAAA
  71. rArAdDU8IHTUPCJ0EoN9EAF+CoN9+AF1BKr/TRDr4awKwHQWPCJ02IN9EAF+CoN9
  72. +AF1BKr/TRDr5TLAqmHJwgwA6AYAAABQ6KUDAABVi+yDxPRXU1Zq9uinAwAAo2BR
  73. QABq9eibAwAAo2RRQACNRfhQ/zVgUUAA6IEDAAC4n////yNF+IPIEFD/NWBRQADo
  74. iAMAAOjn/v//UI9F9P9N9IN99AB1E4M9VzBAAAB0BenyAAAA6d!A5!zwKNXMEAA
  75. aIAAAABoYDBAAP919Ojv/v//aDgwQADowQIAAGg7MEAA6LcCAABoPjBAAOitAgAA
  76. aEEwQABoYDBAAOhBAwAAC8B0DlCPBUswQABQjwVXMEAAaEQwQABoYDBAAOggAwAA
  77. C8B0LYM9TzBAAAB1Dv91+I8FWzBAAOlMAQAA/zVPMEAA/zVgUUAA6NACAADpNgEA
  78. AA+2HWAwQACA+zByHoD7OXcZaGAwQADoWQIAAFCPBU8wQABqAY8FVzBAAIM9VzBA
  79. AAB0BekU////agCNRfxQaidoADBAAP81ZFFAAOiHAgAA6eEAAADoXwIAAFCPBVMw
  80. QAD/NUcwQABYPTgwQAB1Nf81TzBAAFgBBVMwQADowQAAAAvAdAXpiQAAAOgqAgAA
  81. OwVTMEAAcwlqAegzAgAA69zrcetvPTswQAB1LP81TzBAAFgBBVMwQADo/AEAADsF
  82. UzBAAHMJagHoBQIAAOvq6G8AAADrPus8PT4wQAB1NTPAOwVPMEAAdQ7ozAEAAFCP
  83. BVswQADrQOi+AQAAOwVPMEAAdgfoOgAAAOsJagHowAEAAOvjaGAxQADoxgEAAFBb
  84. agCNRfxQU2hgMUAA/zVkUUAA6KEBAAD/NVswQABYXltfycNVi+yDxNBTM8BQj0XQ
  85. /zVLMEAAW41F6FBqAY1F7FD/NWBRQADoVAEAAIN96AB1B/910FhbycONRehQagGN
  86. RexQ/zVgUUAA6DgBAAAzwGaLRexQj0Xkg/gBdS2D+wJ1CIN98AB1AuutZotF+lCP
  87. ReBmi0X2UI9F3P918I9F2P91/I9F1OtE6zaD+AJ1MYP7AnUO/3X8W4P7AXUF6XX/
  88. //9mi0XwUI9F4GaLRfJQj0Xc/3X0j0XY/3X8j0XU6wxqAujLAAAA6Uv/////ddT/
  89. ddj/ddz/deD/deRoJzBAAGhoUUAA6MAAAACDxBxoaFFAAGhgMUAA6KIAAABqAY9F
  90. 0IMFWzBAAAHpCv///1WL7P91CGhgMEAA6JMAAAALwHQQ/3UIjwVHMEAAUI8FVzBA
  91. AMnCBABVi+xXU/91COhiAAAAUFkzwFBb/3UIX2oKW/fjih+A6zADw0fi8VtfycIE
  92. AMz/JQAgQAD/JQQgQAD/JQggQAD/JQwgQAD/JRAgQAD/JRQgQAD/JRggQAD/JRwg
  93. QAD/JSAgQAD/JSQgQAD/JSggQAD/JSwgQAD/JTQgQACLTCQEi1QkCFNWuP////++
  94. AQAAAAPGD7YcCDocEHU2hdt0LQPGD7YcCDocEHUnhdt0HgPGD7YcCDocEHUYhdt0
  95. DwPGD7YcCDocEHUJhdt1xF5bwggAM8BeW8II!A28!
  96. !A64!
  97. !A64!
  98. !A64!
  99. !A64!
  100. !A21!LQgAADCIAAA1CAAAOYgAAD2IAAABiEAABohAAAuIQAA
  101. QCEAAEghAABUIQAAYCE!A7!B6IQ!A7!Hgg!A13!GwhAAAAIAAA
  102. rC!A14!hiEAADQg!A29!LQgAADCIAAA
  103. 1CAAAOYgAAD2IAAABiEAABohAAAuIQAAQCEAAEghAABUIQAAYCE!A7!B6IQAA
  104. !A5!JsARXhpdFByb2Nlc3MA5gBHZXRDb21tYW5kTGluZUEA8gBHZXRDb25zb2xl
  105. TW9kZQAAagFHZXRTdGRIYW5kbGUAAI0BR2V0VGlja0NvdW50AAAeAlBlZWtDb25z
  106. b2xlSW5wdXRBADQCUmVhZENvbnNvbGVJbnB1dEEAbgJTZXRDb25zb2xlTW9kZQAA
  107. twJTbGVlcAD3AldyaXRlRmlsZQAPA2xzdHJjYXRBAAAZA2xzdHJsZW5BAABrZXJu
  108. ZWwzMi5kbGwAAH0Cd3NwcmludGZBAHVzZXIzMi5kbGw!A21!
  109. !A64!
  110. !A64!
  111. v8nRobLOyv2julsvdyAvcyAvZ10gWy9jXSBbL21dIFtudW1dAAoAJWQgJWQgJWQg
  112. JWQgJWQNCgAvdwAvcwAvZwAvYwAvbQ!A34!
  113. !A64!
  114. !A64!
  115. !A64!
  116. !A64!
  117. !A64!
  118. !A64!
  119. !A64!
  120. !A64!
  121. !A43!=
  122. -----END CERTIFICATE-----
复制代码

TOP

mk /g %time%
发一个节奏控制,演示!
  1. @echo off&setlocal enabledelayedexpansion
  2. title 俄罗斯方块按键测试,按【Esc】键可退出。
  3. for %%a in (1037 1039 1040 13232 11313 12727) do set /a n+=1,k%%a=n
  4. rem 按键   【左      右     下     空格    回车    Esc】
  5. set t=%time%
  6. set /a a=%t:~0,2%,b=1%t:~3,2%-100,c=1%t:~6,2%-100,odt=a*3600+b*60+c
  7. rem 计算时间
  8. mk.exe /g
  9. set tt=%errorlevel%
  10. :loop
  11. set /a tt+=25
  12. rem 1000 / 25 = 40 ,控制节奏为:40次/秒
  13. mk.exe /g /c %tt% >tt.txt
  14. for /f "tokens=1-5" %%1 in (tt.txt) do (
  15. echo;%%1 %%2 %%3 %%4 %%5
  16. set /a key=k%%1%%2%%3
  17. )
  18. set t=%time%
  19. set /a a=%t:~0,2%,b=1%t:~3,2%-100,c=1%t:~6,2%-100,dt=a*3600+b*60+c-odt
  20. set /a n+=1,zhen=n/dt
  21. rem 计算时间,算出每秒循环次数。
  22. echo;!key! 起动以来流逝时间:%tt% %zhen%次循环/秒
  23. rem for /l %%a in (1,1,100) do ver >nul
  24. if !key! neq 6 goto :loop
  25. echo;测试结束,5 秒后自动关闭。。。
  26. mk.exe /s /c 5000
  27. goto :eof
复制代码

TOP

;所有参数使用小写字母。
;参数错误,显示参数使用格式

;在等待指定的时间内,检查是否有按键,如果有则取出所有按键,并返回。如果没有则到时间后再返回。无按键返回0,有按键时返回码为事件的【数量】
;希望一直等待时,指定一个比较大的数值。
;mk /w [毫秒]

;等待指定的时间后返回,返回时检测是否有按键,有则取出所有按键返回。无按键返回0,有按键时返回码为返回事件的【数量】
;如果指定的时间太长,有点像假死,可以按Ctrl+C强制退出。
;mk /s [毫秒]

;等待到起动以来的时间超过指定时间后返回,返回时检测是否有按键,有则取出所有按键返回。无按键返回0,有按键时返回码为事件的【数量】
;指定的数值为零时,在%errorlevel%返回起动以来的时间,
;此功能可以很好的控制程序的运行节奏
;mk /G [毫秒]

;【/w,/s,/g】不能同时有效,同时使用时,以第一个为准。
;指定2个以上数字时,以第一个为准。

;起用控制台起用鼠标支持,%errorlevel%返回值为原来的状态,可设置为指定的值<num>
;不使用 /m 参数也一样有效,这个功能主要是如果有必要的话,用来恢复原来的模式。
;mk /m
;mk /m <num>

;按键过滤,使得鼠标移动不处理,键盘按下才有效,松开不处理。
;mk /c

;显示文本,支持ansi转义功能。(正在编写)
;mk /e "显示的文本"

;指定返回数据存放的文件名。如果不指定,默认为:“mk.ini” (因为要增加显示功能,将不在使用直接回显再管道接收的方式,正在编写)
;mk /f "文件名"

;回显多行为多个输入事件,需要根据自己需求进行处理。
;mk.exe  只有3.5K
;Encode 再压缩后的,文本只有3K
  1. @echo off&setlocal enabledelayedexpansion
  2. rem 解压并转码
  3. if not exist mk.exe (
  4. setlocal enabledelayedexpansion
  5. for /l %%a in (1,1,100) do set /a n+=1&set t=!t!A&set A!n!=!t!
  6. (
  7. for /f "tokens=*" %%a in ('type "%~dpf0"') do (
  8. if "%%a" equ "-----BEGIN CERTIFICATE-----" set a=开始
  9. if defined a echo;%%a
  10. )
  11. )>mk.exe
  12. Certutil -Decode -f "mk.exe" "mk.exe" > nul
  13. endlocal
  14. )
  15. title   mk.exe 测试,按【ESC】退出!
  16. :loop
  17. for /f "tokens=1-5" %%1 in ('mk.exe /s 50') do (
  18. rem echo;%%1 %%2 %%3 %%4 %%5
  19. set str=无当前无操作
  20. set key=【无】
  21. IF "%%1" equ "2" (
  22. set str=鼠标
  23. if "%%5" equ "1" (set str=移动!str!)
  24. if "%%5" equ "2" (set str=双击!str!)
  25. if "%%5" equ "0" (
  26. if "%%4" equ "0" (set str=松开!str!)
  27. if "%%4" equ "1" (set str=按下!str!左键)
  28. if "%%4" equ "2" (set str=按下!str!右键)
  29. if "%%4" equ "4" (set str=按下!str!中键)
  30. )
  31. if "%%5" equ "4" if %%4 gtr 0 (set str=向上滚动!str!) else (set str=向下滚动!str!)
  32. set str=!str!,坐标:%%3行,%%2列
  33. ) else IF "%%1" equ "1" (
  34. set str=键盘
  35. if "%%4" equ "1" (set str=按下!str!) else (set str=松开!str!)
  36. if "%%2" equ "0" (set str=!str!扫描码是:%%3,状态码是:%%5) else (set str=!str!ASCII码是:%%2,状态码是:%%5&set key=%%2 - %%3)
  37. ) else IF "%%1" equ "4" (
  38. set str=改变了窗口大小为:行:%%3,列:%%2。
  39. )
  40. echo;!str!,按键 !key!
  41. )
  42. set /a n+=1
  43. title mk.exe 测试,循环 !n! 次, %time%,按Esc键退出。
  44. if "%key%" neq "27" goto :loop
  45. echo;测试结束,按任意键或者等待【5秒】后自动退出。
  46. mk /w 100 >nul
  47. mk /w 5000 >nul
  48. goto :eof
  49. -----BEGIN CERTIFICATE-----
  50. TVqQAAMAAAAEAAAA//8AALg!A9!Q!A31!
  51. !A16!u!A5!4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5v
  52. dCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJ!A10!Z2aFVXbjPBl24zwZduM8G
  53. 06fcBk+4zwahmN0GX7jPBlJpY2hduM8G!A21!FBFAABMAQMA
  54. EAvAYQ!A10!4AAPAQsBBQwABgAAACQ!A7!DCEAAAAB!A5!g!A5!EAA
  55. AB!A5!CAAAE!A10!Q!A10!G!A5!E!A9!w!A6!EAAAEAAA
  56. AAAQAAAQ!A8!E!A15!PCAAADw!A25!
  57. !A64!
  58. !A23!gAAA8!A36!
  59. LnRleHQAAABMBQAAAB!A5!GAAAAB!A19!IAAAYC5yZGF0YQAA
  60. kgEAAAAg!A5!gAAAAo!A18!EAAAEAuZGF0YQAAAOghAAAAMAAA
  61. AAIAAAAM!A18!BAAAD!A33!
  62. !A64!
  63. !A64!
  64. !A64!
  65. !A64!
  66. !A64!
  67. !A64!
  68. !A64!
  69. !A64!
  70. !A64!
  71. !A21!FWL7IPE/GDHRfw!A5!6I8EAACL8PysCsB0IDwgdPdO
  72. /0X8rArAdBM8IHTqPCJ186wKwHQGPCJ19+voYYtF/MnDVYvsg8T4YP9FCMdF/AAA
  73. AACLfQzoSAQAAIvw/KwKwHRYPCB0907/RfzHRfg!A5!i0UIO0X8dQfHRfgBAAAA
  74. rArAdDU8IHTUPCJ0EoN9EAF+CoN9+AF1BKr/TRDr4awKwHQWPCJ02IN9EAF+CoN9
  75. +AF1BKr/TRDr5TLAqmHJwgwA6AYAAABQ6M8DAABVi+yDxPRXU1Zq9ujRAwAAo2BR
  76. QABq9ejFAwAAo2RRQACNRfhQ/zVgUUAA6KsDAAC4n////yNF+IPIEFD/NWBRQADo
  77. sgMAAOjn/v//UI9F9P9N9IN99AB1E4M9VzBAAAB0BenyAAAA6d!A5!zwKNXMEAA
  78. aIAAAABoYDBAAP919Ojv/v//aDgwQADo7AIAAGg7MEAA6OICAABoPjBAAOjYAgAA
  79. aEEwQABoYDBAAOhxAwAAC8B0DlCPBUswQABQjwVXMEAAaEQwQABoYDBAAOhQAwAA
  80. C8B0LYM9TzBAAAB1Dv91+I8FWzBAAOlMAQAA/zVPMEAA/zVgUUAA6PoCAADpNgEA
  81. AA+2HWAwQACA+zByHoD7OXcZaGAwQADohAIAAFCPBU8wQABqAY8FVzBAAIM9VzBA
  82. AAB0BekU////agCNRfxQaidoADBAAP81ZFFAAOixAgAA6eEAAADoiQIAAFCPBVMw
  83. QAD/NUcwQABYPTgwQAB1Nf81TzBAAFgBBVMwQADowQAAAAvAdAXpiQAAAOhUAgAA
  84. OwVTMEAAcwlqAehdAgAA69zrcetvPTswQAB1LP81TzBAAFgBBVMwQADoJgIAADsF
  85. UzBAAHMJagHoLwIAAOvq6G8AAADrPus8PT4wQAB1NTPAOwVPMEAAdQ7o9gEAAFCP
  86. BVswQADrQOjoAQAAOwVPMEAAdgfoOgAAAOsJagHo6gEAAOvjaGAxQADo8AEAAFBb
  87. agCNRfxQU2hgMUAA/zVkUUAA6MsBAAD/NVswQABYXltfycNVi+yDxNBTM8BQj0XQ
  88. /zVLMEAAW41F6FBqAY1F7FD/NWBRQADofgEAAIN96AB1B/910FhbycMzwGaLRexQ
  89. j0Xkg/gBdS2D+wJ1CIN98AB1AutzZotF+lCPReBmi0X2UI9F3P918I9F2P91/I9F
  90. 1Otv60yD+AJ1MIP7AnUL/3X8W4P7AXUC6z5mi0XwUI9F4GaLRfJQj0Xc/3X0j0XY
  91. /3X8j0XU6zrrF4P4BHUSZotF8FCPReBmi0XyUI9F3OshagXo9AAAAI1F6FBqAY1F
  92. 7FD/NWBRQADo0wAAAOk1////jUXoUGoBjUXsUP81YFFAAOi5AAAA/3XU/3XY/3Xc
  93. /3Xg/3XkaCcwQABoaFFAAOi/AAAAg8QcaGhRQABoYDFAAOihAAAAagGPRdCDBVsw
  94. QAAB6d/+//9Vi+z/dQhoYDBAAOiYAAAAC8B0EP91CI8FRzBAAFCPBVcwQADJwgQA
  95. VYvsV1P/dQjoYQAAAFBZM8BQW/91CF9qClv344ofgOswA8NH4vFbX8nCBAD/JQAg
  96. QAD/JQQgQAD/JQggQAD/JQwgQAD/JRAgQAD/JRQgQAD/JRggQAD/JRwgQAD/JSAg
  97. QAD/JSQgQAD/JSggQAD/JSwgQAD/JTQgQADMzMzMzMyLTCQEi1QkCFNWuP////++
  98. AQAAAAPGD7YcCDocEHU2hdt0LQPGD7YcCDocEHUnhdt0HgPGD7YcCDocEHUYhdt0
  99. DwPGD7YcCDocEHUJhdt1xF5bwggAM8BeW8II!A28!
  100. !A64!
  101. !A64!
  102. !A64!
  103. !A21!LQgAADCIAAA1CAAAOYgAAD2IAAABiEAABohAAAuIQAA
  104. QCEAAEghAABUIQAAYCE!A7!B6IQ!A7!Hgg!A13!GwhAAAAIAAA
  105. rC!A14!hiEAADQg!A29!LQgAADCIAAA
  106. 1CAAAOYgAAD2IAAABiEAABohAAAuIQAAQCEAAEghAABUIQAAYCE!A7!B6IQAA
  107. !A5!JsARXhpdFByb2Nlc3MA5gBHZXRDb21tYW5kTGluZUEA8gBHZXRDb25zb2xl
  108. TW9kZQAAagFHZXRTdGRIYW5kbGUAAI0BR2V0VGlja0NvdW50AAAeAlBlZWtDb25z
  109. b2xlSW5wdXRBADQCUmVhZENvbnNvbGVJbnB1dEEAbgJTZXRDb25zb2xlTW9kZQAA
  110. twJTbGVlcAD3AldyaXRlRmlsZQAPA2xzdHJjYXRBAAAZA2xzdHJsZW5BAABrZXJu
  111. ZWwzMi5kbGwAAH0Cd3NwcmludGZBAHVzZXIzMi5kbGw!A21!
  112. !A64!
  113. !A64!
  114. v8nRobLOyv2julsvdyAvcyAvZ10gWy9jXSBbL21dIFtudW1dAAoAJWQgJWQgJWQg
  115. JWQgJWQNCgAvdwAvcwAvZwAvYwAvbQ!A34!
  116. !A64!
  117. !A64!
  118. !A64!
  119. !A64!
  120. !A64!
  121. !A64!
  122. !A64!
  123. !A64!
  124. !A43!=
  125. -----END CERTIFICATE-----
复制代码

TOP

怎么找不到下载的地方呢?

TOP

强大,只是我不知道怎么用在菜单选择上

TOP

返回列表