Chinaunix首页 | 论坛 | 博客
  • 博客访问: 510522
  • 博文数量: 100
  • 博客积分: 2058
  • 博客等级: 大尉
  • 技术积分: 1029
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-14 23:29
文章分类
文章存档

2011年(94)

2010年(6)

分类:

2011-02-14 13:03:40

1、RubyWindows 下读取键盘输入
  1. require 'Win32API'

  2. def getch
  3.   @getch ||= Win32API.new('crtdll', '_getch', [], 'L')
  4.   @getch.call
  5. end

  6. while (c = getch) != ?\e
  7.   puts "You typed #{c.chr.inspect}"
  8. end
复制代码
2、Ruby 在 Windows 下获取当前鼠标光标的位置
  1. result = "0"*8   # Eight bytes (enough for two longs)
  2. getCursorXY = Win32API.new("user32","GetCursorPos",["P"],"V")
  3. getCursorXY.call(result)
  4. x, y = result.unpack("LL")  # Two longs
复制代码
阅读(2512) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~