-1

I want to do following things to be done my Java project:-

  1. Lock Windows desktop.
  2. Detect key press event when windows desktop is locked.
  3. Save entered keys from keyboard in a text file.

First step is done using this code:

Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\\Windows\\System32\\rundll32.exe user32.dll,LockWorkStation");
halfer
  • 19,824
  • 17
  • 99
  • 186
  • 5
    Java is the wrong language for this, though I'm not sure it should be done at all. – Andrew Thompson Oct 01 '12 at 13:18
  • 1
    Why do you want to log key presses when passwords are entered? – Mitch Satchwell Oct 01 '12 at 13:18
  • 3
    Mh, locking a workstation is exactly that: Locking a workstation. Just as trapping Ctrl-Alt-Del is a "protected" keystroke that you cannot easily trap, the logon screen is totally separated from the user's desktop screen. In Windows API, there is the concept of a "WinStation". What runs on the user´s "WinStation" is totally isolated from what runs when the logon screen is shown. Which mean you won´t easily write an app that executes on the user´s desktop and monitors the keystrokes that are typed when the logon screen is active. At least not using official (documented) Windows APIs. – TheBlastOne Oct 01 '12 at 13:21
  • You could write a system-wide keyboard monitor, but you will have a hard time getting that one certificated/signed as "compatible"/"trusted". – TheBlastOne Oct 01 '12 at 13:24
  • Though i just want to turn on webcam when a key is pressed – Vivek Kumar Oct 01 '12 at 13:32

1 Answers1

1

User Applications will never be able to do this due to security concerns. However, you can get around the restriction if you use a driver to intercept input at a lower level. This StackOverflow question discusses a similar problem. The linked driver looks like a good fit for your purpose.

Community
  • 1
  • 1
mensi
  • 9,580
  • 2
  • 34
  • 43