04-09-2018 07:04 AM
I have a program that runs in the background.
I would like to change the behavior of the code if the screen has been locked (windows-L)
How can I find out if the screen has been locked?
Solved! Go to Solution.
04-09-2018 08:51 AM
.NET system events will send a signal.
You'll need to use a callback VI, but you can put a user event in it to make the callback VI send a user event to a normal event structure.
I think you need SessionSwitch, and then examine the SessionSwitchReason (lock or unlock).
04-09-2018 09:08 AM
Just a quick and dirty example. It needs work, but shows the principle...
04-09-2018 09:56 AM
Thank you for replying to my qestion.
Just like many times the answer cause more questions.
This is a type of LabVIEW programming that is unfamiliar to me.
I tried to create the callback vi but I have no idea what the event data should be
My only experience with callbacks has been with TestStand operator interface code and I did not know they were even used elsewhere.
If it is not too much trouble can you demo a dummy callback vi that would connect to this registered even?
Thanks
04-09-2018 10:00 AM
You must have been sending this as I was typing my question.
04-09-2018 10:24 AM
I was able to add this to my code, and get it to work.
It seems to me that when the screen is locked the event will generate a 7, and when the screen is unlocked it generates an 8.
Thanks
P.S.
Now I know about (aware of) something else that I don't know about..
04-10-2018 03:05 AM
You're welcome.
Those callbacks are pretty uncommon. They can be great, you can also wire regular LabVIEW control references to them. Then right click to create the callback with the required prototype. They are great because they can implement filters and such, but data is a problem. Since they are started once, it's hard to get them to use actual\current data. You need DVR's or buffers. The great thing is you don't have to stop them. They stop automatically when the calling VI stops. For .NET and ActiveX they are the only way to get events...
04-10-2018 06:47 AM - edited 04-10-2018 06:47 AM
The solution you have provided will work by catching the event when the screen is locked or unlocked.
Is there a way to poll/query for the state of the the locked screen?
Also in a side not for the life of me I can't figure out how to put a LabVIEW control refence on the block diagram connected to the Reg Event Callback and right click on it to make the callback vi with the correct prototype
04-10-2018 07:39 AM
@RustyStrings wrote:
The solution you have provided will work by catching the event when the screen is locked or unlocked.
Is there a way to poll/query for the state of the the locked screen?
No easy way as far as I can tell. I'll dig around a bit (I'm sure I did it at some point).
@RustyStrings wrote:
Also in a side not for the life of me I can't figure out how to put a LabVIEW control refence on the block diagram connected to the Reg Event Callback and right click on it to make the callback vi with the correct prototype
On a terminal (or control) right click and select Create>Reference. Wire it to the Register Event Callback. Then select an event. Then, right click the RECN and select create callback. Pretty sure the last step is disabled when no valid reference is wired or when no event was selected.
04-10-2018 08:00 AM
It is amasing how you can miss something right in front of you.
I see now that all I had to do was right click on the Reg Event Callback at the VI Ref location and Create Callback is an option.
I think I was expexting it to be a sub menu of the create menu.
Thanks for you help !