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?
  • Comment on Re^3: How to execute win32 functions when the user session is locked.

Replies are listed 'Best First'.
Re^4: How to execute win32 functions when the user session is locked ( hwndSendKeys )
by Anonymous Monk on Feb 06, 2014 at 08:41 UTC

    Here is hwndSendKeys , its close, but its broken (and i'm bored with it)

    sub hwndSendKeys { my ( $hwnd, $keys, $delay) = @_; $delay = 25 unless defined $delay; $delay /= 1000; my @k = Win32::GuiTest::parse_keys($keys); for ( my $i = 0; $i < @k; $i+=2) { if ( defined $k[$i]) { Win32::GuiTest::DbgShow("SendRawKey(@k[$i,$i+1])\n"); #~ Win32::GuiTest::SendRawKey( @k[$i,$i+1]); my( $key, $updown ) = @k[ $i, $i+1 ] ; my $wmupdown = WM_KEYDOWN(); $wmupdown = WM_KEYUP() if $updown == 2; Win32::GuiTest::PostMessage( $hwnd, $wmupdown, $key , 0 + ); select(undef,undef,undef,$delay); ## deprecated $i+=2; ### SUPER BROKEN otherwise DOUBLING bug } else { $k[$i+1]-> (); } } }