If you give everything an object name, Get (ActiveLayoutObjectName) should tell you the name of the current layout object that has the focus. If it's always a field, you won't need to assign object names, you can use Get(ActiveFieldName) to determine the name of the field that currently has the cursor.
Sometimes it works best to pass such info as a parameter to the script.
Thanks. I now have a matrix of fields which I click and then having selected one I hit a button which reads the active field then opens the relevant part of the data base. It means I have 2 clicks to do but that works.
Use a dropdown list or pop-up menu that lists the places your user might want to select. Use a script trigger to fire a script that goes to the location slected from the drop down when they either exit the field ( drop down ) or modify it ( pop-up ).
If you prefer a button grid. Use the paramter setting to pass a value, such as a layout name to the script the button is set to perform:
All the buttons could then use the same script:
Go To Layout [ Get ( ScriptParameter ) ] (Use layout name or layout number by calculation options)
Of course, if you need more sophisticated things to be done besides switching layouts (such as different sorts and finds for different layouts), you can use a series of If-ElseIF-Else-EndIF steps to perform different operations based on the parameter sent to the script.
Either way, you don't have to do two button clicks just to go to a particular layout.
This is great I wish I had found out about triggers before