Re: SetVisibleInTiger
Re: SetVisibleInTiger
- Subject: Re: SetVisibleInTiger
- From: kai <email@hidden>
- Date: Sun, 21 Aug 2005 01:02:11 +0100
On 16 Aug 2005, at 03:43, Jeff Porten wrote:
On Aug 2, 2005, at 7:34 AM, kai wrote:
This works quite well here:
-------------------
to toggleVisible(f)
tell application "System Events" to set f's visible to not f's
visible
tell application "Finder"
update f
tell (get f's folder)'s container window to if exists then
close
repeat while exists
delay 0.1
end repeat
open
end if
end tell
end toggleVisible
toggleVisible(choose file)
A possibly simpler solution, with Developer Tools installed:
do shell script "/Developer/Tools/SetFile -a V " & quoted form of
POSIX path of (theFile)
It might appear to be simpler, Jeff - although I wonder if we might
be comparing apples with oranges here...
The OP was evidently trying to come up with a script that toggles the
visibility of a file. As I indicated in the part of my message that
you omitted, my suggestion therefore aims to:
1) check whether or not the target file is visible
2) if it is visible, then make it invisible (otherwise make it
visible)
3) update the file's representation in Finder.
However, if immediate visual confirmation of the file's changed state
is required, it's necessary to workaround a current bug that (in
spite of the update command) prevents such changes from showing in a
currently open Finder window[1]. So the script goes on to:
4) determine if the container window of the file's folder is open
5) if it is, then close it...
6) ...wait until it is closed - and then...
7) ...reopen it (all of which usually does the trick).
While the above shell script sets a file's visible property to false,
the method is then subject to exactly the same issues. In fact, its
vanilla equivalent could be something as simple as:
----------------
tell application "System Events" to set theFile's visible to false
----------------
...which, besides not having to rely on the presence of Developer
Tools, is slightly shorter (FWIW), easier to read (IMO) - and about
four times faster (OMM). :-)
---
kai
[1] <rdar://problem/2832251> SYNC:Finder doesn't notice visible bit
changing
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden