In most cases, there is a special key or sequence of keystrokes that make the host return to a specific screen (e.g., Main Menu or Logon screen). You can write an action routine that synchronizes the host with the ESL program by bringing both back to a specific point.
Another method is to use the ECS subroutine EcsEmulateAndWatch, which brings the emulator to the foreground until a known screen is encountered. At this point, ESL causes the emulator to relinquish control to the ESL program. You can define which screens cause ESL to regain control by creating a screen ID file. Copy the name of this file to a string variable, and pass the variable, as an argument, to EcsEmulateAndWatch. The name of the screen, which is defined in the screen ID file, is returned by EcsEmulateAndWatch. Upon returning, the emulator window is returned to the appearance that it held prior to calling this subroutine.