Ruby 在 Windows 下对鼠标键盘的读取
1、Ruby 在 Windows 下读取键盘输入require 'Win32API'def getch
@getch ||= Win32API.new('crtdll', '_getch', [], 'L')
@getch.call
end
while (c = getch) != ?\e
puts "You typed #{c.chr.inspect}"
end2、Ruby 在 Windows 下获取当前鼠标光标的位置result = "0"*8 # Eight bytes (enough for two longs)
getCursorXY = Win32API.new("user32","GetCursorPos",["P"],"V")
getCursorXY.call(result)
x, y = result.unpack("LL")# Two longs 不错啊。
页:
[1]