Morthawt Posted October 7, 2014 Share Posted October 7, 2014 (edited) #RequireAdmin AdlibRegister('ctrlaltdel') While 1 ; Rest of your script goes here, just make sure it does not self-exit else the script won't keep running, obviously. Sleep(250) WEnd Func ctrlaltdel() Local Static $_PrevActive $Active = WinActive('[ACTIVE]') If Not $Active Then $_timer = TimerInit() Sleep(0) ; Increase from 0 (in milliseconds) if a delay is desired before action is performed. ; Actions directly below to perform upon detection of secure desktop AdlibUnRegister('ctrlaltdel') Do Sleep(100) Until WinActive('[ACTIVE]') AdlibRegister('ctrlaltdel', 250) If TimerDiff($_timer) > 0 Then ; Increase from 0 (in milliseconds) if you want a minimum time on secure desktop before action is performed. ; Actions directly below to perform upon detection of secure desktop being no longer being active. EndIf WinActivate($_PrevActive) EndIf $_PrevActive = $Active EndFunc ;==>ctrlaltdel This started because I wanted to add some code to an automation script which runs ragged while blocking user input so that if I press ctrl alt delete it would terminate. Because while usually ctrl alt del does negate the effect of a BlockInput, due to the speed of my script it was not always working. So I was thinking, investigating methods that might yield results and I got the perfect results based on my circumstance. The thing is it does not just detect ctrl alt delete, but it detects if you press win + L to lock the computer, or you have UAC on and want to run a program as admin and the secure desktop comes up. So I am releasing this in the example code section in a form that may be useful to some people. I have added an area you can perform a command as soon as the secure desktop is detected, plus added an area where you can perform commands after the secure desktop is no longer active. You do not have to perform actions in both, it can be either. I have also added delays so that you could have actions performed at the detection of the secure desktop happen X milliseconds after it is detected, or have actions performed AFTER the secure desktop has gone away but only if the secure desktop was active for X milliseconds or more (for example locking your PC and walking away, after X time and you log back in Y happens but nothing would happen if a quick action to give a program admin was needed because the time was not long enough) If you have any thoughts on this or think it could be useful I would appreciate hearing from you. EDIT: Added a #RequireAdmin to make sure it can get window ID's of all user-based windows. Edited October 7, 2014 by Morthawt Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. 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