Web Terminal screen automation features

Green Screens Web Terminal screen data among other information also contains screen hashes that can be used to identify currently active screen.

Screen hashes opens very interesting possibilities like screen scrapping, screen automation or integration with other 3rd party web applications.

Each screen contains two hashes:

  • Field hash – each screen might contain fields with their position in screen matrix. Hash is calculated from those positions identifying hash for specific field mask.

  • Attributes hash – each screen contains screen color attributes mask inside screen matrix. Hash is calculated from those attributes to get unique id for color mask.

Why 2 hashes? Multiple screens can have the same number of fields and same position of fields thus we generate attribute hash also to help differentiate screens with the same fields hash.

Another reason for 2 hashes is screen messages. For example, login screen will always have unique field hash and multiple attribute hashes depending on screen attribute mask. This way we can identify different screen responses like standard screen, error screen etc.

NOTE: In a case of two distinct screens with the same field and attribute hashes other options are available like matching specific text on the screen.

To get current screen hashes use following example:

var obj = Tn5250.Application.getConfig();
console.log(obj.fldHash);
console.log(obj.attrHash);

Hash generator

Hash generator is process of preparing screen hash tree structure for screen detection. Once, generated, tree structure can be mapped to functions to be called automatically when screen is detected by given hash mapping.

Here is the easiest way to generate screen hash tree:

  • Select text on the screen (in single line)
  • Press ALT + M to save screen hash
  • Go to the next screen and repeat text selection and keyboard shortcut
  • When finished with maping, press SHIFT +ALT + M to save generated hash tree structure

Single screen can have multiple mappings. For example, if there is a need to detect screen scrolling, we can map various screen areas to create multiple matches. For example to detect when screen reach the end of scrolling (usually have Bottom text at the bottom right corner.)

Hash executor

Hash executor is internal API used to register specific JSON object containing screen hashes and attached hash functions.

Following example shows script used to skip first screen after login (message information screen). First hash is field hash while second hash is screen attribute mask. We have to use both hashes here as many screens without fields will have exactly the same field hash.

  function onSessionMessage() {
      Tn5250.Keyboard.sendEvent('ENTER');
  }

  var callbacks = {
   '13423423432' : {
     cb : onSessionMessage
   }
  };
  
  var hashes = {
    'ref' : {
       '13423423432' : {
         'static' : true,
         'hash' : '343BE4F3598833919B0C514E6E3C152EFE324E3A',
         'row' : 0,
         'col' : 0,
         'val' : ''
      }
    },
    '50E5078D23FA0AAD9CDDF74957B224F3E5740D95' : {      
       'ref' : 13423423432
    },
  };

  // listen for application startup event
  $(window).on('greenscreens', function() {
     // register screen hash definition for execution service
     Tn5250.Application.register(hashes, callbacks);
  });

This is very simple showcase how to link custom functions to be executed for specific terminal screens. Here we have just scratched the surface. Possibilites are limitless.

To give you a hint, take for an example integration with Google Drive or Google Doc through JavaScript Google API or integration with MS Office 365. There is one more very interesting product with powerful web api that enable integration directly within browser - Onlyoffice.