Hi @dublove have a look at this:
(function () {
var doc = app.activeDocument,
item = doc.selection[0];
if (!item)
alert('You have nothing selected.');
if ('Image' === item.constructor.name)
alert('You have selected a graphic.');
if (
item.hasOwnProperty('graphics')
&& 1 === item.graphics.length
)
alert('You have selected an image frame.');
if ('TextFrame' === item.constructor.name)
alert('You have selected a text frame.');
if (
item.hasOwnProperty('texts')
&& 1 === item.texts.length
)
alert('You have selected something with text.');
if ('InsertionPoint' === item.constructor.name)
alert('Your cursor is in the text');
if (
'InsertionPoint' === item.constructor.name
&& 'Cell' === item.parent.constructor.name
)
alert('Your cursor is in a table row.');
if (
// table cell selections are always 'Cell'
'Cell' === item.constructor.name
// two rows
&& 2 === item.rows.length
// rows are first and second
&& 0 === item.rows[0].index
&& 1 === item.rows[1].index
// both whole rows are selected
&& item.cells.length == item.rows.everyItem().cells.length
)
alert('You have selected the top two rows of the table.');
})();