Project1

标题: 关于禁止键盘按键的问题 [打印本页]

作者: jiahui5592986    时间: 2012-7-22 13:30
标题: 关于禁止键盘按键的问题
本帖最后由 jiahui5592986 于 2012-7-22 13:31 编辑

求下脚本,或方法,禁止某些键盘按钮.例如我想禁止键盘上的:CTRL ,X【禁止按下菜单等按钮】dsu_plus_rewardpost_czw
作者: 亿万星辰    时间: 2012-7-22 14:27
事件操作里有禁止打开菜单,ON了即可。
CTRL键本来也没有这个操作。
作者: jiahui5592986    时间: 2012-7-22 14:43
亿万星辰 发表于 2012-7-22 14:27
事件操作里有禁止打开菜单,ON了即可。
CTRL键本来也没有这个操作。

- -有全键盘脚本就没有禁止键盘的脚本么
作者: Wind2010    时间: 2012-7-22 16:22
本帖最后由 Wind2010 于 2012-7-22 16:25 编辑
  1. =begin

  2.   屏蔽按键

  3.   作者:秀秀

  4.   使用方法: 1. Maskkey.mask (屏蔽按键)
  5.    
  6.             2. Maskkey.maskAllKey (屏蔽所有按键)
  7.             
  8.             3. Maskkey.stopMask (恢复按键)
  9. =end  

  10. module Maskkey
  11.   # 默认屏蔽 F1,F2
  12.   # 需要屏蔽其他按键自行加入即可(ASCII码)
  13. F1 = 0x70
  14. F2 = 0x71
  15.   KeyCode = [F1,F2]
  16.   
  17.   Mask = Win32API.new("MaskKey.dll","StartMaskKey","pii","i")
  18.   StopMask = Win32API.new("MaskKey.dll","StopMaskKey","v","v")
  19.   
  20.   def self.mask
  21.     Mask.call(KeyCode.pack("L*"),12,0)
  22.   end  

  23. def self.maskAllKey
  24.    Mask.call("",0,1)
  25. end  

  26. def self.stopMask
  27.    StopMask.call
  28. end  

  29. end  
复制代码

作者: 亿万星辰    时间: 2012-7-22 18:34
jiahui5592986 发表于 2012-7-22 14:43
- -有全键盘脚本就没有禁止键盘的脚本么

有是有的,我是觉得你想要的功能没必要那么做……
作者: jiahui5592986    时间: 2012-7-23 09:47
Wind2010 发表于 2012-7-22 16:22

会出错 是不是需要个DLL文件???
作者: katonghu    时间: 2012-7-23 14:18
需要一个MaskKey.dll。
注:下载完毕后将文件名改为MaskKey.dll即可使用,无需打开。(添加的附件好像不支持DLL。)

MaskKey.rar

28 KB, 下载次数: 37

DLL文件


作者: jiahui5592986    时间: 2012-7-23 16:56
katonghu 发表于 2012-7-23 14:18
需要一个MaskKey.dll。
注:下载完毕后将文件名改为MaskKey.dll即可使用,无需打开。(添加的附件好像不支 ...

我就认为wind2010少了什么DLL
作者: jiahui5592986    时间: 2012-7-23 17:06
katonghu 发表于 2012-7-23 14:18
需要一个MaskKey.dll。
注:下载完毕后将文件名改为MaskKey.dll即可使用,无需打开。(添加的附件好像不支 ...

貌似不可以哦
作者: 折戬沉沙    时间: 2012-7-23 21:14
[X]键:要是只是想禁用菜单的话,用时间就好了。

[CTRL]键:只有在RMXP测试时才生效,直接从运行game.exe是无效的。
作者: jiahui5592986    时间: 2012-7-24 09:44
zxcgood2009 发表于 2012-7-23 21:20
我说你有必要没。
开始游戏后F1,把x换成别的键,不就得了。
或者把,按下x键后,播放短暂的空白音乐,不做 ...

那Ctrl呢?游戏发布的时候呢.这个方法¥@#¥#


‘‘──jiahui5592986于2012-7-24 09:45补充以下内容:

有效.........
’’
作者: hys111111    时间: 2012-7-24 12:29
可以将你的全键盘脚本换一下。
判断方法(以A键为例):Input.press?(65)
冻结方法(以B键为例):Input.disable(66)
取消冻结方法(以C键为例):Input.able(67)
对应按键的列表:
LETTERS['A'] = 65; LETTERS['B'] = 66; LETTERS['C'] = 67; LETTERS['D'] = 68
  LETTERS['E'] = 69; LETTERS['F'] = 70; LETTERS['G'] = 71; LETTERS['H'] = 72
  LETTERS['I'] = 73; LETTERS['J'] = 74; LETTERS['K'] = 75; LETTERS['L'] = 76
  LETTERS['M'] = 77; LETTERS['N'] = 78; LETTERS['O'] = 79; LETTERS['P'] = 80
  LETTERS['Q'] = 81; LETTERS['R'] = 82; LETTERS['S'] = 83; LETTERS['T'] = 84
  LETTERS['U'] = 85; LETTERS['V'] = 86; LETTERS['W'] = 87; LETTERS['X'] = 88
  LETTERS['Y'] = 89; LETTERS['Z'] = 90
  NUMBERS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
  NUMPAD = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
  BACK   = 138; ENTER  = 143; SPACE  = 32;  SCOLON = 186; ESC    = 157
  QUOTE  = 222; EQUALS = 187; COMMA  = 188; USCORE = 189; PERIOD = 190
  SLASH  = 191; LBRACE = 219; RBRACE = 221; BSLASH = 220; TILDE  = 192
  F10    = 121; F11    = 122; CAPS   = 20;  NMUL   = 106; NPLUS  = 107
  NSEP   = 108; NMINUS = 109; NDECI  = 110; NDIV   = 111; Extras =
  [USCORE, EQUALS, LBRACE, RBRACE, BSLASH, SCOLON, QUOTE, COMMA, PERIOD, SLASH,
   NMUL, NPLUS, NSEP, NMINUS, NDECI, NDIV]


下面是脚本(直接插入)
  1. #===============================================================================
  2. #
  3. # OriginalWij and Yanfly Collaboration - Keyboard Input
  4. # Last Date Updated: 2010.06.12
  5. # Level: Normal
  6. #
  7. # This is a utility script that provides the functionality to return inputs
  8. # from the keyboard as well as free up more keys to be used in the Input module.
  9. # This script will also replace Scene_Name and allow for direct keyboard input
  10. # to type in an actor's name as well as fix the maximum characters shown from
  11. # the default base script.
  12. #
  13. #===============================================================================
  14. # Updates
  15. # -----------------------------------------------------------------------------
  16. # o 2010.06.12 - Started and Finished Script.
  17. #===============================================================================
  18. # Instructions
  19. # -----------------------------------------------------------------------------
  20. # To install this script, open up your script editor and copy/paste this script
  21. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  22. #
  23. # For users:
  24. #   The Name Input event has been now replaced. It not longer takes you to the
  25. #   name entry scene, but instead, allows the player to enter in the name of
  26. #   the desired actor right in the current screen itself without needing to
  27. #   change the scene altogether.
  28. #
  29. # For scripters:
  30. #   For those curious as to how to retrieve certain letters while coding their
  31. #   Input commands, use the following as reference
  32. #   
  33. #   LETTERS['A'] through LETTERS['Z']
  34. #     This returns true if the respective letter from A through Z is pressed.
  35. #   
  36. #   NUMBERS[0] through NUMBERS[9]
  37. #     This returns true if the respective number on the top row of the keyboard
  38. #     is pressed. This does not include the numberpad.
  39. #   
  40. #   NUMPAD[0] through NUMPAD[9]
  41. #     This returns true if the respective number in the number pad is pressed.
  42. #     This does not include the numbers found at the top row of the keyboard.
  43. #   
  44. #   Symbol Keys
  45. #     
  46. #     USCORE  - This returns true if the - key is pressed.
  47. #     EQUALS  - This returns true if the = key is pressed.
  48. #     SCOLON  - This returns true if the ; key is pressed.
  49. #     QUOTE   - This returns true if the ' key is pressed.
  50. #     COMMA   - This returns true if the , key is pressed.
  51. #     PERIOD  - This returns true if the . key is pressed.
  52. #     SLASH   - This returns true if the / key is pressed.
  53. #     BSLASH  - This returns true if the \ key is pressed.
  54. #     LBRACE  - This returns true if the [ key is pressed.
  55. #     RBRACE  - This returns true if the ] key is pressed.
  56. #     TILDE   - This returns true if the ~ key is pressed.
  57. #   
  58. #   Command Keys
  59. #     
  60. #     BACK    - This returns true if the backspace key is pressed.
  61. #     ENTER   - This returns true if the enter/return key is pressed.
  62. #     SPACE   - This returns true if the space bar is pressed.
  63. #     ESC     - This returns true if the escape key is pressed.
  64. #   
  65. #   Module Methods
  66. #     
  67. #     Input.typing?
  68. #       To check if typing is occurring. Returns true or false.
  69. #     
  70. #     Input.key_type
  71. #       Returns whatever key is being used to type as a string.
  72. #   
  73. #   Example:
  74. #   
  75. #     if Input.typing?
  76. #       string = Input.key_type
  77. #     end
  78. #
  79. #===============================================================================

  80. $imported = {} if $imported == nil
  81. $imported["KeyboardInput"] = true

  82. #===============================================================================
  83. # Editting anything past this point may potentially result in causing computer
  84. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  85. # Therefore, edit at your own risk.
  86. #===============================================================================

  87. #===============================================================================
  88. # Input
  89. #===============================================================================

  90. class << Input  
  91.   #--------------------------------------------------------------------------
  92.   # Aliases (Mods - Linked to Module) - Created by OriginalWij
  93.   #--------------------------------------------------------------------------
  94.   alias ow_dt_i_press press? unless $@
  95.   alias ow_dt_i_trigger trigger? unless $@
  96.   alias ow_dt_i_repeat repeat? unless $@
  97.   alias ow_dt_i_update update unless $@
  98. end

  99. module Input
  100.   #--------------------------------------------------------------------------
  101.   # constants - Created by OriginalWij and Yanfly
  102.   #--------------------------------------------------------------------------
  103.   LETTERS = {}        
  104.   LETTERS['A'] = 65; LETTERS['B'] = 66; LETTERS['C'] = 67; LETTERS['D'] = 68
  105.   LETTERS['E'] = 69; LETTERS['F'] = 70; LETTERS['G'] = 71; LETTERS['H'] = 72
  106.   LETTERS['I'] = 73; LETTERS['J'] = 74; LETTERS['K'] = 75; LETTERS['L'] = 76
  107.   LETTERS['M'] = 77; LETTERS['N'] = 78; LETTERS['O'] = 79; LETTERS['P'] = 80
  108.   LETTERS['Q'] = 81; LETTERS['R'] = 82; LETTERS['S'] = 83; LETTERS['T'] = 84
  109.   LETTERS['U'] = 85; LETTERS['V'] = 86; LETTERS['W'] = 87; LETTERS['X'] = 88
  110.   LETTERS['Y'] = 89; LETTERS['Z'] = 90
  111.   NUMBERS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
  112.   NUMPAD = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
  113.   BACK   = 138; ENTER  = 143; SPACE  = 32;  SCOLON = 186; ESC    = 157
  114.   QUOTE  = 222; EQUALS = 187; COMMA  = 188; USCORE = 189; PERIOD = 190
  115.   SLASH  = 191; LBRACE = 219; RBRACE = 221; BSLASH = 220; TILDE  = 192
  116.   F10    = 121; F11    = 122; CAPS   = 20;  NMUL   = 106; NPLUS  = 107
  117.   NSEP   = 108; NMINUS = 109; NDECI  = 110; NDIV   = 111; Extras =
  118.   [USCORE, EQUALS, LBRACE, RBRACE, BSLASH, SCOLON, QUOTE, COMMA, PERIOD, SLASH,
  119.    NMUL, NPLUS, NSEP, NMINUS, NDECI, NDIV]

  120.   #——————————————————————————————
  121.   # 冻结
  122.   #————————————————————————————
  123.   def able(key)
  124.     @disable = [] if @disable == nil
  125.     @disable.delete(key)
  126.   end
  127.   def disable(key)
  128.     @disable = [] if @disable == nil
  129.     @disable.push(key)
  130.   end
  131.   #--------------------------------------------------------------------------
  132.   # initial module settings - Created by OriginalWij and Yanfly
  133.   #--------------------------------------------------------------------------
  134.   GetKeyState = Win32API.new("user32", "GetAsyncKeyState", "i", "i")
  135.   GetCapState = Win32API.new("user32", "GetKeyState", "i", "i")
  136.   KeyRepeatCounter = {}
  137.   module_function
  138.   #--------------------------------------------------------------------------
  139.   # alias method: update - Created by OriginalWij
  140.   #--------------------------------------------------------------------------
  141.   def update
  142.     ow_dt_i_update
  143.     for key in KeyRepeatCounter.keys
  144.       next if @disable.include?(key)
  145.       if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  146.         KeyRepeatCounter[key] += 1
  147.       else
  148.         KeyRepeatCounter.delete(key)
  149.       end
  150.     end
  151.   end
  152.   
  153.   #--------------------------------------------------------------------------
  154.   # alias method: press? - Created by OriginalWij
  155.   #--------------------------------------------------------------------------
  156.   def press?(key)
  157.     return if @disable.include?(key)
  158.     return ow_dt_i_press(key) if key < 30
  159.     adjusted_key = adjust_key(key)
  160.     return true unless KeyRepeatCounter[adjusted_key].nil?
  161.     return key_pressed?(adjusted_key)
  162.   end
  163.   
  164.   #--------------------------------------------------------------------------
  165.   # alias method: trigger? - Created by OriginalWij
  166.   #--------------------------------------------------------------------------
  167.   def trigger?(key)
  168.     return if @disable.include?(key)
  169.     return ow_dt_i_trigger(key) if key < 30
  170.     adjusted_key = adjust_key(key)
  171.     count = KeyRepeatCounter[adjusted_key]
  172.     return ((count == 0) or (count.nil? ? key_pressed?(adjusted_key) : false))
  173.   end
  174.   
  175.   #--------------------------------------------------------------------------
  176.   # alias method: repeat? - Created by OriginalWij
  177.   #--------------------------------------------------------------------------
  178.   def repeat?(key)
  179.     return if @disable.include?(key)
  180.     return ow_dt_i_repeat(key) if key < 30
  181.     adjusted_key = adjust_key(key)
  182.     count = KeyRepeatCounter[adjusted_key]
  183.     return true if count == 0
  184.     if count.nil?
  185.       return key_pressed?(adjusted_key)
  186.     else
  187.       return (count >= 23 and (count - 23) % 6 == 0)
  188.     end
  189.   end
  190.   
  191.   #--------------------------------------------------------------------------
  192.   # new method: adjust_key - Created by OriginalWij
  193.   #--------------------------------------------------------------------------
  194.   def adjust_key(key)
  195.     return if @disable.include?(key)
  196.     key -= 130 if key.between?(130, 158)
  197.     return key
  198.   end
  199.   
  200.   #--------------------------------------------------------------------------
  201.   # new method: key_pressed? - Created by OriginalWij
  202.   #--------------------------------------------------------------------------
  203.   def key_pressed?(key)
  204.     return if @disable.include?(key)
  205.     if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  206.       KeyRepeatCounter[key] = 0
  207.       return true
  208.     end
  209.     return false
  210.   end
  211.   
  212.   #--------------------------------------------------------------------------
  213.   # new method: typing? - Created by Yanfly
  214.   #--------------------------------------------------------------------------
  215.   def typing?
  216.     return true if repeat?(SPACE)
  217.     for i in 'A'..'Z'
  218.       return true if repeat?(LETTERS[i])
  219.     end
  220.     for i in 0...NUMBERS.size
  221.       return true if repeat?(NUMBERS[i])
  222.       return true if repeat?(NUMPAD[i])
  223.     end
  224.     for key in Extras
  225.       return true if repeat?(key)
  226.     end
  227.     return false
  228.   end
  229.   
  230.   #--------------------------------------------------------------------------
  231.   # new method: key_type - Created by Yanfly
  232.   #--------------------------------------------------------------------------
  233.   def key_type
  234.     return " " if repeat?(SPACE)
  235.     for i in 'A'..'Z'
  236.       next unless repeat?(LETTERS[i])
  237.       return upcase? ? i.upcase : i.downcase
  238.     end
  239.     for i in 0...NUMBERS.size
  240.       return i.to_s if repeat?(NUMPAD[i])
  241.       if !press?(SHIFT)
  242.         return i.to_s if repeat?(NUMBERS[i])
  243.       elsif repeat?(NUMBERS[i])
  244.         case i
  245.         when 1; return "!"
  246.         when 2; return "@"
  247.         when 3; return "#"
  248.         when 4; return "$"
  249.         when 5; return "%"
  250.         when 6; return "^"
  251.         when 7; return "&"
  252.         when 8; return "*"
  253.         when 9; return "("
  254.         when 0; return ")"
  255.         end
  256.       end
  257.     end
  258.     for key in Extras
  259.       next unless repeat?(key)
  260.       case key
  261.       when USCORE; return press?(SHIFT) ? "_" : "-"
  262.       when EQUALS; return press?(SHIFT) ? "+" : "="
  263.       when LBRACE; return press?(SHIFT) ? "{" : "["
  264.       when RBRACE; return press?(SHIFT) ? "}" : "]"
  265.       when BSLASH; return press?(SHIFT) ? "|" : "\\"
  266.       when SCOLON; return press?(SHIFT) ? ":" : ";"
  267.       when QUOTE;  return press?(SHIFT) ? '"' : "'"
  268.       when COMMA;  return press?(SHIFT) ? "<" : ","
  269.       when PERIOD; return press?(SHIFT) ? ">" : "."
  270.       when SLASH;  return press?(SHIFT) ? "?" : "/"
  271.       when NMUL;   return "*"
  272.       when NPLUS;  return "+"
  273.       when NSEP;   return ","
  274.       when NMINUS; return "-"
  275.       when NDECI;  return "."
  276.       when NDIV;   return "/"
  277.       end
  278.     end
  279.     return ""
  280.   end
  281.   
  282.   #--------------------------------------------------------------------------
  283.   # new method: upcase? - Created by Yanfly
  284.   #--------------------------------------------------------------------------
  285.   def upcase?
  286.     return !press?(SHIFT) if GetCapState.call(CAPS) == 1
  287.     return true if press?(SHIFT)
  288.     return false
  289.   end
  290.   
  291. end # Input
复制代码

作者: katonghu    时间: 2012-7-24 18:25
jiahui5592986 发表于 2012-7-23 17:06
貌似不可以哦

不会吧,屏蔽按键可以使用。只不过效果不太稳定,好像只有在特定的情况下发挥作用。
比如说主角死亡时执行屏蔽按键就起作用了,你可以试一试。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1