I think what you are looking for is something like on of the below.
automationObject.autoTypeJS('xxxx'); //place cursor in location to enter data on screen
automationObject.sendFunction('Home'); //to move cursor to home position
automationObject.sendFunction('Tab'); //tab to next unprotected field
automationObject.getText(24,12,24,30); //get data from screen
these 2 functions can be an issue with the clipboard if the clipboard is being used by other applications
automationObject.sendFunction('Copy'); //copy data to clipboard
automationObject.sendFunction('Copy and Append');
using variables
a1 = ["1", "zzz", "2", "yyy"]; //array
variable2(a[bb]); //bb is a javascript for loop
variable1 = 'some data';
automationObject.autoTypeJS(variable1);
using the clipboard to retain data, I do these functions:
alert("Click OK then copy data to clipboard");
variable1 = automationObject.getText(24,12,24,30); //get data from screen
navigator.clipboard.writeText(variable1); //copy variable to clipboard
alert("Click OK then paste from clipboard to document");