I'm backed into a corner and I see no way out. I'm going to be forced to abandon my trusty XP machine and start using Win7 for my daily activities. I know what you're thinking. How could this happen in a civilized society? I can't provide an answer. I only know that its really happening. *sigh*
In any case I've been looking for a method to detect windows logout and login primarily when I press Winkey + L on a Win7 computer. Under XP I could capture the key press using OnEvent>, under Win7 I cannot. Under XP when the computer is locked the desktop is black (actually color code -1) which can be detected using GetPixelColor>. Under Win7 that is no longer true. The Win7 desktop is fully detectable using colors or images even while the screen is locked after a Winkey + L logout.
I have googled detect logout, detect screen lock, etc. and found tons of misinformation but nothing that is an absolute certainty about detecting the logged out condition. Not even an absolute certainty of what to call the condition. The one thing that seems to be working on my Win7 computer is detecting the logonui.exe process. However it seems to me that logonui.exe also runs when a computer has had users switched so I'm not sure this is a sure fire way to detect the screen locked condition.
Does anyone have a good method for detecting the condition created by pressing Winkey + L on a Win7 / Win8 computer?
Detect Windows Logout/Login
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7380
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Detect Windows Logout/Login
TBH - I don't know but this surprised me:
I would have expected it to go black.The Win7 desktop is fully detectable using colors or images even while the screen is locked after a Winkey + L logout.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Detect Windows Logout/Login
This was true under WinXP.I would have expected it to go black.
Paste the following in the editor. Note the time on your computer so you have a frame of reference for the WaitScreenImage> timing. Run the script. (From the editor is fine.) If the process logonui.exe is not running, the script should loop continuously and not display any messages. My experience is that while the screen on a Windows computer is locked, the process logonui.exe is running. When the screen is not locked, logonui.exe is not running.
This script waits for the process logonui.exe. When the process starts the script performs a couple of image functions to see if they work while the screen is locked, then puts up a modal message with the image function results.
After starting the script, press WinKey + L to lock the screen. Wait a minute or two so you can be sure that the message time is noticeably prior to your logging back in. Log back in and look at the message.
Assuming all works for you as it does for me, you'll see a modal message that starts with the time for the moment WaitScreenImage> saw its image and moved on. You'll see a number for a color from GetPixelColor and you'll see a 1 (one) indicating that FindImagePos> found one image on the screen. Basically the three functions all performed correctly while the screen is locked on my Windows 7 computer.
ScreenCapture> also works while the screen is locked. Have not tested any other functions. Might be interesting to test the text capture functions too but don't have time at the moment.
Code: Select all
ScreenCapture>700,300,800,400,%temp_dir%POC.bmp
Label>Loop
ProcessExists>logonui.exe,vRes
If>vRes=True
Wait>2
GetPixelColor>10,10,vColor
FindImagePos>%temp_dir%POC.bmp,SCREEN,200,1,Xpos,Ypos,NumFound
WaitScreenImage>%temp_dir%POC.bmp
GetTime>vTime
MDL>%vTime% %vColor% %NumFound%
Wait>1
EndIf
Wait>1
Goto>Loop
- CyberCitizen
- Automation Wizard
- Posts: 721
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Re: Detect Windows Logout/Login
Could You Read The Event Log Looking For The Log Out Error Code.
FIREFIGHTER