Hello.
The script in post #12 is updated.
I have just changed the script to make it work as fast as possible, it turned out that finder does select its folders the fastest way.
I tried to select folders like below, by creating a script object, containing the select statement for the folders in the current finder window:
set X to (current date)
tell application id "MACS"
activate
tell its front window
if current view of it is not list view then
set current view of it to list view
end if
set pxFolderPath to POSIX path of (its target as alias)
end tell
end tell
set selFolderStatement to (do shell script "cd " & quoted form of pxFolderPath & "; find -P . -depth 1 -prune -type d -print |grep -Ev '(app \\(|bundle'\\$'|app'\\$'|prefPane'\\$'|vpdoc'\\$')' |sed -n 's_^\\./\\([^/]*\\)_folder \\\\\"\\1\\\\\"_p' |tr '
' ','")
try
set selFolderStatement to text 1 thru -2 of selFolderStatement & " "
on error
return -- nothing to be done, no folders to select
end try
set scriptbody to "{\"tell application id \\\"MACS\\\"
tell its front window
select {" & selFolderStatement & "}
tell application id \\\"sevs\\\"
key down command
key down option
key down shift
key code 124
key up shift
key up option
key up command
end tell
select its first item
end tell
end tell\"}"
set b to (run script scriptbody)
try
run script b
on error e number n
tell application "SystemUIServer"
activate
display dialog "You probably need to add to the grep statement in tree.app in order to exclude a bundle of some kind, the error message is on the clipboard" buttons {"Ok"} default button 1 with icon stop
set the clipboard to (e & n)
end tell
end try
set Y to (current date) - X
log Y
This turned out to be one second slower however, when I wanted to expand a folder with 158 subfolders, in comparision to the old way of letting finder handle it.
I deleted the “working.” dialogs, as I never managed to unblock them, I also seemed to create a zombie process in the process (pun…) that seemed to get the app hang. But, if the user moves the mouse slightly away from the toolbar cursor, then the beach-ball should appear immediately, and that is progress good enough for me.
The cache I talked about, was somewhat badly worded, I really meant the script object that contained the id’s of the windows, now it contains both the id of the window, and its target as text, so you must delete the old one before starting the new version of the toolbar-applet.
And if there is someone to be thanked here, hey! it was your idea, I love it, and, hadn’t it been for the other guys around here, I never would have been able to make it.