QUESTION: How do you find out which item the cursor is currently sitting on? I'm thinking of something like scriptCmdData.func.sourcetab.cursored
PURPOSE: In the unlikely event that this can't be done already, could I suggest it as a very useful addition to the tab object. Just as one example, it would then be possible to write a script so that you could:
select a number of files,
then place the cursor on a particular file, say ThisFile.txt,
then process the selected files using some of the properties, or content, or whatever, of ThisFile.txt.
The selected files to be processed could even be on the other panel (or even on another lister) — imagine the possibilities if it worked in FlatView!
My idea was that the selected files are all processed. The single cursored file (which would normally not be a selected file) would provide properties, or metadata, or attributes, or content, or whatever you may dream up, that you could use when processing the selected files.
EASY WORKAROUND: Two buttons.
With Button 1, select a single file (say MasterFile), then Button 1 places its path into a fixed-name file in the %Temp% directory.
With Button 2, select the files to be processed, then Button 2 finds the fixed-name %Temp% file, reads the path of MasterFile that is named there, finds MasterFile and gets whatever information it wants from it, and processes the selected files using this information.
If JScript could tell me the cursored file, say with scriptCmdData.func.sourcetab.cursored, that would save one button. In any case, "What item is the cursor on?" is a reasonable question to ask from within a JScript.
Wait a minute!!! "Cursor" may be totally the wrong word!!! I don't mean the arrowhead controlled by the mouse — I mean the rectangular box around the filename that moves up and down with the arrow keys, and remains around a selected item even after the command Select * Deselect.
I don't think there is a way to get the cursor/focus item, but scripts can differentiate from selected and checked (separate properties in the Item object), if the tab is in checkbox mode, which may give you another way to do it.
After some more fiddling about, I've decided that the two-button approach is after all the best way to go, because it is more flexible — it allows the reference item to be used repeatedly, in different directories, and for different purposes. It's also less prone to fat-finger errors.
The first button requires that exactly one reference item has been selected. It reads the full path of that reference item, then creates a file with fixed filename PathOfReferenceItem.txt in C:\ProgramData\GPSoftware\Directory Opus\User Data (or wherever), then writes the full path of the reference item to it. That makes any aspect or contents of the reference item easily available to any script in a second button.