How to get runtime os system using ruby?

I have a ruby ​​script. I want to know how long the system has been idle (i.e. Does not interact with the user - based on the activation of the splash screen).

I believe that I can do this in ruby ​​through win32api using user32.dll and GetLastInputInfo, but I cannot figure out how ... can anyone help me?

.

+3
source share
3 answers

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')
# match the structure LASTINPUTINFO. First 4 byte int is size of struct
s = [8, 0].pack('l*')
api.call( s )
a = s.unpack('l*')
puts a
+3
source
0

Based on a response from Mark Wilkins, I created several scripts to record user downtime.

https://gist.github.com/Largo/11216868

0
source

Source: https://habr.com/ru/post/1730094/


All Articles