LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mouse Keyboard inactivity logout

I want LAbVIEW to logout of a program if there is no keyboard or mouse activity.

 

Is there a simple VI to monitor when the last keyboard or mouse activity occurred?  Or is this something that is available in activex?

 

The question was asked before but the resolution isn't really that helpful:

https://forums.ni.com/t5/LabVIEW/quit-lv-for-keyboard-inactivity/m-p/2305336#M725398

 

The VI quoted is this : Input Device Control\Monitoring Keyboard and Mouse Activity.vi

 

It has to be run continuously and loses events, for example if I put the timer to 1 second and press the keys at the wrong time, the event is lost.

 

Is there any VI that will just return the time of the last mouse/ keyboard event or at least one that retains the events for more than a second?  

0 Kudos
Message 1 of 10
(4,062 Views)

Try this one instead: Wait For Front Panel Activity

to avoid continous poll.

 

Untitled.png

 

George Zou
Message 2 of 10
(4,030 Views)

Thanks George,

 

That's almost what I need, except I need it to occur in an event timeout that needs to keep running.

 

If there was anyway it could just report the time of the last event it would be ideal.

 

Rgds,

Seán

0 Kudos
Message 3 of 10
(4,025 Views)

I just tried wait for front panel activity and it is worse than I expected.

 

Moving the mouse does not produce and event nor does clicking on an area that is not a control/ indicator.

 

Basically, I am looking for the same functionality as a screensaver.  Any ideas?

0 Kudos
Message 4 of 10
(3,994 Views)

I think that functionality is buried somewhere within Windows.  Maybe a Web Search would locate this -- try using "Windows Screensaver" or "How to start Screensaver" as a topic.

 

Bob Schor

0 Kudos
Message 5 of 10
(3,980 Views)

Create an event structure with three events: one to watch the mouse, one to watch keys, and a timeout with your desired wait wired into the event structure.

 

Then, any time you move the mose or hit a key, you trigger an event.  The loop cycles back.  If it ever reaches timeout, neither the mouse nor keyboard were hit.  You don't need to know the last time they were hit.  The timeout handles that for you.

0 Kudos
Message 6 of 10
(3,973 Views)

Hi Bob,

 

Thanks for that, this actually looks like it might be what I need:

 

https://www.autohotkey.com/docs/Variables.htm#User_Idle_Time

 

I'll get back if I actually get it working, (for the time being I've just introduced another loop which is not ideal).

0 Kudos
Message 7 of 10
(3,971 Views)

This can be a way to find the inactivity in mouse an keyboard.

0 Kudos
Message 8 of 10
(2,796 Views)

@Rajansh wrote:

This can be a way to find the inactivity in mouse an keyboard.


True, but you are polling again, and I would (almost) always choose an event-driven solution over a polling solution.  An extreme example of polling vs event-driven code can be seen when modding with scripts for some games.  Running a script that continuously polls certain variables can actually cause the game to crash, whereas waiting on an event that would change that same variable gives the game engine a break.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 9 of 10
(2,780 Views)

inactivity test.JPG

 I have modified your program and tried it like this. It works perfectly for key and mouse inactivity with low refresh rate. Every key stroke and mouse movement is detected 100 %

Message 10 of 10
(113 Views)