OK, “what” I want applescript to do is very simple.
I want applescript to show the path of the finder window when the finder window which was clicked,
for example:
Click “Documents” window, it’s a finder window of a folder, then it will show “HD:User:XXX:Documents”
by
=========
tell application “Finder”
set target_window to window 1
set target_path to target of target_window as text
display dialog target_path
end tell
Everything works well except when Desktop was clicked,
every Finder window could become “window 1” except Desktop itself,
if I opened the desktop folder as a finder window, of course it could work fine,
but it was unable to make the “Desktop” surface which lies below all windows to become “window 1”.
That means even if I clicked on the Desktop, the “frontmost window” (or window 1, whatever) still would be the last window which I’ve clicked on but not the Desktop, so it was unable to get the path of Desktop when the Desktop surface was clicked on.
Does it make any sense?
What I want is just to get the path of Desktop by “moving the mouse cursor over the Desktop surface and clicking on it”.
The possible way I could imagine is to call Cocoa NSevent, when the “mouse click” event happened, calculate it’s cursor position,
if this curson position without any window lying on, then the surface which was clicked on must be the Desktop.
Could anyone share the detail way? Thanks sincerely.