查看: 2239|回复: 0

[已经过期] 请问这几段代码所写的方法的具体作用是?

[复制链接]
梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
回帖
2257

贵宾

发表于 2012-12-20 19:27:41 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 Sion 于 2013-2-8 14:12 编辑

就是21行开始定义的方法


  1. module Kboard

  2.   $R_Key_A         = 0x41        # A key
  3.   $R_Key_B         = 0x42        # B key
  4.   $R_Key_C         = 0x43        # C key
  5.   $R_Key_D         = 0x44        # D key
  6.   $R_Key_E         = 0x45        # E key
  7.   $R_Key_F         = 0x46        # F key
  8.   $R_Key_G         = 0x47        # G key
  9.   $R_Key_H         = 0x48        # H key

  10.   #楼主已经将中间无数按键的定义省略

  11.   GetKeyState = Win32API.new("user32","GetAsyncKeyState",['I'],'I')
  12.   GetKeyboardState = Win32API.new("user32","GetKeyState",['I'],'I')
  13.   GetSetKeyState = Win32API.new("user32","SetKeyboardState",['I'],'I')

  14.   #--------------------------------------------------------------------------

  15.   module_function

  16.   def keyb(rkey)
  17.     if GetKeyState.call(rkey) != 0
  18.       return 1
  19.     end
  20.     return 0
  21.   end

  22.   def keyboard(rkey)
  23.     GetKeyState.call(rkey) & 0x01 == 1  
  24.   end
  25.   
  26.   def key(rkey, key = 0)
  27.     GetKeyboardState.call(rkey) & 0x01 == key
  28.   end
  29. end
复制代码
编辑一下,之前只贴了半截……
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部