From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-14-2018 05:39 AM
Hi,
How can I detect when a user has logged ON/OFF or Unlocked/Locked the screen in Windows?
I would like to trigger an event in my code to restart or end a subroutine whenever the user is present only.
Regards,
Jega
Solved! Go to Solution.
08-14-2018 01:52 PM
You can poll who the user is with this:
08-14-2018 07:10 PM - edited 08-14-2018 07:12 PM
.NET to the rescue!
Register for a .NET event:
You can delete the structure and the timing VI and replace it with your real code... just don't unregister til you're ready to exit.
This is an example of a callback VI... all it does is a popup telling you what kind of session switch happened:
Example code attached. Just replace the popup window with something that sends a signal to your program as a user event, queue, whatever that a session change has occurred.
08-14-2018 07:24 PM
Kyle97330,
Can you save it under LabVIEW 2013 or earlier? I am on LabVIEW 2013 SP1.
Regards,
Jega
08-15-2018 10:59 AM
Attached. Sorry it took a while, I went home right after posting that yesterday.
08-15-2018 08:04 PM
Kyle97330,
This is awesome!... Exactly what I needed. Thank you.
Quick question, do we need the Event Common Data, Control Ref and User Parameter variables in the Callback VI?
08-16-2018 11:06 AM
The callback VI has to have a connection pane that matches exactly what the event registration expects, so they need to stay there and connected to the pane, even if unused. When using the .NET "Register event callback" node, you right-click it and choose "Create callback VI" and it creates one for you that has the correct pane.
(Side note: Since it seems to work, you can go ahead and click "Mark as solution" so future forum searchers find it easier...)
08-18-2018 11:40 PM
Thank you so much Kyle97330.