oookotooo Posted June 27, 2018 Share Posted June 27, 2018 Hi, I have a stopwatch measuring my screen time. I need a script which will pause (send("^1")) my stopwatch when i lock my sceen. All scripts I found here can not understand that screen was locked until it is unlocked. Here they are, bad examples: Func _IsLocked() ; Both functions can't understand that screen is locked now, script only can see that screen WAS locked only after PC is UNLOCKED... Local $fIsLocked = False Local Const $hDesktop = _WinAPI_OpenDesktop('Default', $DESKTOP_SWITCHDESKTOP) If @error = 0 Then $fIsLocked = Not _WinAPI_SwitchDesktop($hDesktop) _WinAPI_CloseDesktop($hDesktop) EndIf Return $fIsLocked EndFunc ;==>_IsLocked Func _IsWorkstationLocked() Local $Result = False $hDesktop = DllCall('user32.dll', 'hwnd', 'OpenDesktop', 'str', 'Default', 'int', 0, 'int', 0, 'int', $DESKTOP_SWITCHDESKTOP) If Not @error Then $Result = DllCall('user32.dll', 'int', 'SwitchDesktop', 'hwnd', $hDesktop[0]) $Result = Not $Result[0] DllCall('user32.dll', 'int', 'CloseDesktop', 'hwnd', $hDesktop[0]) EndIf Return $Result EndFunc ;==>_IsWorkstationLocked Maybe someone has an Idea how to detect screen locking action, and do something just right in time of locking? Link to comment Share on other sites More sharing options...
Dragonfighter Posted June 27, 2018 Share Posted June 27, 2018 Maybe that can help you You can try to first get the Power Scheme GUID that is activated and then read Registry and get the value in seconds that inside the key "Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\7516b95f-f776-4464-8c53-06167f40cc99\8EC4B3A5-6868-48c2-BE75-4F3044BE88A7\DefaultPowerSchemeValues\here go the Power Scheme GUID that is activated" and then check when mouse is not moving and start doing a countdown if mouse move it restart checking if mouse is not moving. Link to comment Share on other sites More sharing options...
Earthshine Posted June 27, 2018 Share Posted June 27, 2018 (edited) would you not have to hook the lock-screen windows message handler to intercept it first? https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_SetWindowsHookEx.htm Edited June 27, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
junkew Posted June 27, 2018 Share Posted June 27, 2018 ex19a_events.au3 in IUIAutomation thread of examples can help you out and before you ask it see FAQ 31 and no you cannot catch ctrl+alt+del key in a normal way (you can google why) on my system W10 when i do ctrl+alt+delete and choose lock screen I get below event $iEventId = 20016 Title = Schakelen tussen taken Class = MultitaskingViewFrame Ctrl type = 50032 Ctrl name = venster Value = Handle = 00181C8E $iEventId = 20016 Title = Windows-standaardvergrendelingsscherm Class = Windows.UI.Core.CoreWindow Ctrl type = 50032 Ctrl name = venster Value = Handle = 00010278 $iEventId = 20017 Title = Windows-standaardvergrendelingsscherm Class = Windows.UI.Core.CoreWindow Ctrl type = 50032 Ctrl name = venster Value = Handle when i do ctrl+alt+delete I get taskmanager window event $iEventId = 20016 Title = Schakelen tussen taken Class = MultitaskingViewFrame Ctrl type = 50032 Ctrl name = venster Value = Handle = 00181C8E $iEventId = 20016 Title = Windows-standaardvergrendelingsscherm Class = Windows.UI.Core.CoreWindow Ctrl type = 50032 Ctrl name = venster Value = Handle = 00010278 $iEventId = 20017 Title = Windows-standaardvergrendelingsscherm Class = Windows.UI.Core.CoreWindow Ctrl type = 50032 Ctrl name = venster Value = Handle when i do ctrl+alt+delete change password I get NO EVENT but maybe more events can be caught as in base example it only filters on events with visible windows FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now