• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: SetVisibleInTiger
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SetVisibleInTiger


  • Subject: Re: SetVisibleInTiger
  • From: kai <email@hidden>
  • Date: Tue, 2 Aug 2005 12:34:13 +0100


On 2 Aug 2005, at 04:36, DigitEL wrote:

Does anyone know if setting the visible of a file is broken in Tiger or am I missing something in the following script that returns 'Stack Overflow' error:

try
    set theFile to (choose file)
    set itemInfo to (info for theFile)
    if (visible of itemInfo) is true then
        set visible of alias (theFile as string) to false
    else
        set visible of alias (the theFile as string) to true
    end if
on error errM
    display dialog errM
end try

On its own, a file doesn't have a visible property that one can get or set directly. You really need something else (like a suitable application or scripting addition) to do the getting and setting of properties. While the File Commands Suite from Standard Additions has a visible property for file information, it's read only - so it obviously can't help with the setting operation.


It seems slightly curious to me that Finder isn't able to deal with this. Fortunately, System Events can.

However, since Finder doesn't seem to update properly on open windows (looks somewhat buggy to me), a bit of faffin' around might be needed if you want to see a correct representation of the result right away.

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)

-------------------

(BTW, I hope you won't mind my pointing out something else that struck me about the "alias (the theFile as string)" statements in your script. Since theFile is already an alias, coercing it to a string and then back to an alias doesn't really appear to achieve very much.)

:-)

---
kai


_______________________________________________ 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
  • Follow-Ups:
    • Re: SetVisibleInTiger
      • From: Jeff Porten <email@hidden>
References: 
 >SetVisibleInTiger (From: DigitEL <email@hidden>)

  • Prev by Date: Re: SetVisibleInTiger
  • Next by Date: Re: Finder GUI Scripting
  • Previous by thread: Re: SetVisibleInTiger
  • Next by thread: Re: SetVisibleInTiger
  • Index(es):
    • Date
    • Thread