Key presses and mouse actions in locked sessions.

Articles, advices, FAQ, etc.
Post Reply
Oleg
Site Admin
Posts: 3275
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Key presses and mouse actions in locked sessions.

Post by Oleg »

How to ensure autonomous task execution using key presses and mouse actions? The system ignores simulated keystrokes and mouse actions (cursor movement, button clicks) in locked sessions. This is a system security feature and cannot be changed.

Therefore, if you plan to use the task independently in a system service or in a locked session, you should avoid using simulated keystrokes and mouse actions. Generally speaking, keyboard and mouse actions are designed to batch routine user actions during operation. For example, when a certain hotkey combination is pressed, RoboTask will perform a whole set of operations that would normally take the user much longer to complete.

When we leave the computer, the session is usually locked after a certain period of time, and interactive keyboard and mouse actions stop working.
The same effect occurs if we close a remote RDP session. When we disconnect from a session on a remote computer, the session does not close, but enters a locked state and keyboard and mouse actions stop working.

What should you do if you need to use keystrokes and mouse actions without user involvement?
It is logical to assume that the session should be left open. This can be done, but it is not always convenient.
However, there is another way. Starting with Windows 8 (Pro edition) and Windows Server 2008, the Hyper-V component was added to the system, which allows you to use virtual machines.

User interaction with a Hyper-V virtual machine is possible in two modes:
  • Basic session
  • Enhanced session
In enhanced session mode, interaction is very similar to an RDP session. That is, if we interrupt the connection to the user session, the session on the virtual machine automatically goes into a locked state with all the related effects.

The Basic session mode is interesting for our case. If a user has logged into a virtual machine (opened a user session) and closed the connection to the virtual machine, the session remains open. If we reopen the connection to the virtual machine, we will see the open session in the state in which we left it. There is no need to unlock the session and enter authorization parameters. To use Basic mode by default, simply disable Enhanced session in the Hyper-V settings.

This allows us to use tasks with interactive keyboard and mouse actions without any problems. We can close the connection to the virtual machine, and the virtual machine will continue to run in hidden mode, but with the user session open.
In addition, the virtual machine can be started automatically when the computer starts up without opening a user session. That is, it is enough to simply turn on the computer. Auto login on a virtual machine is also easy to achieve using the Autologon utility from Microsoft™.
Oleg Yershov
Post Reply