It is currently December 3rd, 2020, 10:54 am

Away From Keyboard(/mouse) plugin?

Share and get help with Plugins and Addons
nixx3d
Posts: 28
Joined: February 17th, 2014, 2:22 am

Away From Keyboard(/mouse) plugin?

Post by nixx3d »

I'm wondering if there is any way for rainmeter to know if the user has left his computer (doesn't use keyboard/mouse for x time)

I'd like to lower the update rate of my whole skin when the user isn't using his computer and for that need a way to detect this...

is that possible with one of the current plugins/features?

thanks!
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Away From Keyboard(/mouse) plugin?

Post by jsmorley »

Nothing built into Rainmeter if there is some utility that you can run in the background in Windows that can monitor some behavior (mouse or keyboard activity), you might be able to configure that to execute some command, including !Bangs to Rainemter.exe from the command line.
nixx3d
Posts: 28
Joined: February 17th, 2014, 2:22 am

Re: Away From Keyboard(/mouse) plugin?

Post by nixx3d »

ok, will look some more.
Did find a bunch but mostly are related to games.

would be a nice feature to include ;)
Although in most cases it's not really relevant..

thanks!
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Away From Keyboard(/mouse) plugin?

Post by jsmorley »

Not something that jumps out at me as terribly useful, but also not a bad little "bell and whistle" ability.

Might be something with CallNtPowerInformation in a plugin, maybe someone will look into that.

Found this description of how it might work:

There's one simpler way to retrieve system-wide activity on Windows Vista and later OS though. You'll get a "very clunky" output, but it will work system-wide. Call CallNtPowerInformation with SystemPowerInformation and examine the TimeRemaining member of the SYSTEM_POWER_INFORMATION struct. This value will be updated every "now-and-then" if there's no system-wide user activity. The question that I struggled with, is "how often is 'now-and-then'?" The answer doesn't seem to be as straightforward as it seems. It depends on the OS. For Vista it is done every 10 seconds or so, for Windows 7 - every 15 sec, and for Windows 8 - every 30 seconds. For Windows XP though, it is updated ONLY if the "Put computer to sleep" setting in the Power Options in Control Panel is set to something other than "Never". So I would not use it on XP.

Basically it just uses the values that Windows is already setting to track "idle time" for purposes of the Power Plan settings.
nixx3d
Posts: 28
Joined: February 17th, 2014, 2:22 am

Re: Away From Keyboard(/mouse) plugin?

Post by nixx3d »

funny, I was just visiting this page:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383561%28v=vs.85%29.aspx

which suggest it's possible to launch a task when there is no user input (if it can be separated from the cpu thresholds that could be enough + low resources as it's native windows)

Will look into both later this weekend.

I'm using rainmeter (awesome tool btw!) to monitor my (3d) render farm by having the workstation read the openHardwareMonitor reports for all the nodes every x seconds and display that info.

But with 11 computer it's taking up 5-10% of the workstation's cpu when updating every 1-3 seconds.
And as it's often rendering while I'm afk it's then useless to update that often.
Therefor wish to adjust the update rate based on the computer interaction (only keyboard/mouse as cpu etc will be fully used) to save cpu and unnecessary network activity.

just for the fun 2 screenshots attached
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Away From Keyboard(/mouse) plugin?

Post by jsmorley »

I saw that function as well, but it is designed to be used in the context of the application calling it, so it would in effect detect whether there has been any user activity in the Rainmeter skin running the plugin, not the entire system. Not what we would be looking for I don't think.
nixx3d
Posts: 28
Joined: February 17th, 2014, 2:22 am

Re: Away From Keyboard(/mouse) plugin?

Post by nixx3d »

From what I read, this should be it : http://msdn.microsoft.com/en-us/library/ms646302%28VS.85%29.aspx

and here where the second post provides an example script >http://stackoverflow.com/questions/2212823/how-to-detect-inactive-user
function SecondsIdle: DWord;
var
liInfo: TLastInputInfo;
begin
liInfo.cbSize := SizeOf(TLastInputInfo) ;
GetLastInputInfo(liInfo) ;
Result := (GetTickCount - liInfo.dwTime) DIV 1000;
end;

procedure TForm1.Timer1Timer(Sender: TObject) ;
begin
Caption := Format('System IDLE last %d seconds', [SecondsIdle]) ;
end;
but now the question.. can I just 'throw' this in a plugin or do I need to write a plugin for it myself?

note..I have zero programming capabilities..
I already consider it a miracle that I got rainmeter working the way I wanted it :D
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Away From Keyboard(/mouse) plugin?

Post by jsmorley »

You would need to actually write a plugin in either C++ or C#. No real shortcut for that.

http://docs.rainmeter.net/developers
nixx3d
Posts: 28
Joined: February 17th, 2014, 2:22 am

Re: Away From Keyboard(/mouse) plugin?

Post by nixx3d »

Ouch.. I feared so... Thats way over my head..

Will see if I can find another alternative for now.
Not really realistic to expect from myself to learn that in a few hours :)

Thanks!
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Away From Keyboard(/mouse) plugin?

Post by jsmorley »

nixx3d wrote:Ouch.. I feared so... Thats way over my head..

Will see if I can find another alternative for now.
Not really realistic to expect from myself to learn that in a few hours :)

Thanks!
Yeah, agreed, and I don't think that is the best resource to use. If you read the remarks:

This function is useful for input idle detection. However, GetLastInputInfo does not provide system-wide user input information across all running sessions. Rather, GetLastInputInfo provides session-specific user input information for only the session that invoked the function.

Someone might get a wild hair and take a look at this, you never know.