Here is an example that calls GetLastInputInfo. However, I have not studied this API to make sure that it really gives you the information you want.
require "Win32API"
api = Win32API.new( 'user32', 'GetLastInputInfo', ['P'], 'I')
s = [8, 0].pack('l*')
api.call( s )
a = s.unpack('l*')
puts a
source
share