I have a few AppleScripts and OS X 10.6.4 Services containing AppleScripts, which take a Finder selection to process further. This is a simplified example of the Finder selection input:
tell application "Finder"
set selectCount to count selection as list
if selectCount = 0 then
display alert "Nothing was selected"
else
display dialog (selectCount as text) & " selected"
end if
end tell
This works well when there is a multiple item selection, or a single item (file or folder) selected by left-clicking on it. I can then right-click on the selection to access a service to process the selection.
However, if I only mouse over one item and right-click on it to access a service, then no selection is recorded. This is contrary to the normal behaviour when mousing over and right-clicking on an item in the Finder, for instance to assign a label.
How can I modify the script to make it accept the input of a single item selected by mousing over and right-clicking on it? Please help me.