There are several possible approaches you might use to select a particular chat window. One way, of course, would be to capture images of the title of each window and use those in your script. If that’s not practical in your case, you might try cycling through the windows from the keyboard. If your SUT is a Mac, this can be done using Command-Tilde:
There may be a similar mechanism for cycling through windows on other operating systems. By typing this command repeatedly the correct number of times you can activate the desired window.
Another approach that may be more satisfactory although it is slightly more work would be to drag each of your chat windows to a different location on the screen when you first open it. Your script can then record the location for each session window. For example, if you open 4 chat sessions, you could put the window for the first session in the upper left, the second in the upper right, and so forth. Store the window locations in a list and then when you need to activate a particular window your script can click the appropriate location from the list.
After typing a message in the selected window, use the Connect command to switch to a different SUT. The best way to verify that the correct message was received is to select it in the message window and copy the text to the clipboard. Your script can then use the RemoteClipboard() function to retrieve the copied text from the SUT, and compare the text that was received to the text that was sent. Because SenseTalk ordinarily ignores uppercase/lowercase differences when comparing text, you may want to explicitly specify “considering case” if you need to verify that the text was received exactly.
Here’s an example of how this might all look when it comes together (some of the details will depend on the actual SUTs you are connecting to, etc.):
-- assume we have the following already:
-- masterSUT is a property list with connection information for the main SUT
-- receiverSUT1, receiverSUT2, etc. have connection info for other SUTs
-- messageToSend has the text we want to send
-- receiverNumber is set to the number of the chosen receiver (1,2, etc.)
-- windowLocations is a list of window locations for the chat windows
-- connect to the main SUT
-- activate the window for the receiver we want to send a message to:
put item receiverNumber of windowLocations into selectedChatWindowLoc
-- send the message:
typeText return -- (assuming this is how you send the message)
-- switch to the receiver's SUT to see if the message was received:
-- (we dynamically access the variable name for the connection info using value() )
connect value("receiverSUT" & receiverNumber)
-- (assume the receiver's chat window is already the active window)
typeCommand "A" -- select all text (assuming Mac SUT)
typeCommand "C" -- copy to clipboard
-- get the received message and compare it to what was sent
put remoteClipboard() into receivedMessage
if receivedMessage = messageToSend considering case then
put "Success" into messageStatus
put "Failure" into messageStatus
I hope that’s enough to get you started. Let us know if you need additional help making this all work.