Why do UI macros fail when I disconnect or minimize the Remote Desktop/Terminal Services session?

This is related to Can I send keystrokes / mouse events when Windows is locked?.

Windows consists of  Window Stations and Desktops.

From Microsoft's documentation (links above):

  • "The interactive window station, Winsta0, is the only window station that can display a user interface or receive user input. It is assigned to the logon session of the interactive user, and contains the keyboard, mouse, and display device. All other window stations are noninteractive, which means they cannot display a user interface or receive user input."
  • "The desktops associated with the interactive window station, Winsta0, can be made to display a user interface and receive user input, but only one of these desktops at a time is active."

So, when Windows is logged out the only interactive window station is the logon console - the user's desktop doesn't exist. And when Windows is locked the active desktop becomes the logon desktop. The user's desktop ceases to display windows and receive user input. So when you log out of Windows, or lock it, macros aren't able to focus windows or send keyboard or mouse events.

The same thing happens when you disconnect from a Remote Desktop or Terminal Services session - even when you just disconnect the session. The session still exists but the interactive window station doesn't. So any macros that need to focus windows or send keystrokes and mouse events are unable to do so. When you minimize a Remote Desktop session the session is locked - just like when you lock a regular Windows session. The user's desktop is no longer the active desktop.

For more information see:
http://windowssdk.msdn.microsoft.com/en-us/library/ms681928.aspx

Still need help? Contact Us Contact Us