How do I send keyboard & mouse input to the Windows logon screen?

1.3k views Asked by At

I'm working on a windows service that needs to simulate input at the windows logon screen. Basically move mouse and also forward keystrokes. The service will be running with full privileges so that's not an issue. I've looked into SendInput, but it only works for the current session. I know there are various types of tools that allow such functionality e.g. remote assistance tools are one example that allow IT support to view the logon screen and provide input as well, so it's definitely do-able, but how?

2

There are 2 answers

0
Sándor Krisztián On

Gaming mouses can for example can storing password, programming it as a macro, and push a button, then password is sendkeyed.

If you have two monitor, and windows run, you can write Autohotkey macro, move mouse to the rdp window on second monitor, click, and sendkey. This is a basic persistent ahk code, if you push win+L buttons, it logins on second screen.

#l::
  MouseMove, 2000, 810 ;the password field in pixel point on second window
  Sleep, 200
  Click, 1420, 810 
  Sleep, 200
  Send, bazword
  Sleep, 200
  Send, {ENTER}
return
0
Thomas Weller On

SysInternals PSExec has the -x command line switch to run programs on the logon screen.

There is an open source version called PAExec. I guess you'll find some helpful API calls in there. To me it seems the code should be in InteractiveSession.cpp