http://www.perlmonks.org?node_id=1073647


in reply to Re^2: How to execute win32 functions when the user session is locked.
in thread How to execute win32 functions when the user session is locked.

You need to remove the concept of "active window" and "foreground window" from your script. Once your remove those 2, and send the "keys" to the *background*ed window, it will work. http://forums.codeguru.com/showthread.php?313632-quot-Sendkeys-quot-problem-while-computer-locked . Notice SendKeys doesn't ask for a HWND. You need something that takes a HWND or object equivalent. SendKeys is a wrapper for http://msdn.microsoft.com/en-us/library/windows/desktop/ms646304%28v=vs.85%29.aspx. If the lock screen is the foreground window, where do you think your key presses will go assuming they aren't blocked for security reasons?