Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > AppleScripting the Finder

AppleScripting the Finder
Thread Tools
Glennfield
Junior Member
Join Date: Dec 2001
Location: My own personal purgatory
Status: Offline
Reply With Quote
Apr 23, 2002, 06:05 PM
 
This received no responses on the Developer forum in five days, so I'm moving it here. Surely I can't be the only one with this problem.

I'm having trouble with an AppleScript called "Tandem" (from http://www.macosxhints.com/article.p...11127022706921 ) - specifically, it worked under OS X before, but since at least the 10.1.3 update, it hasn't.

My code, which is a slight variation of the original, but worked before the update:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>

set startup_disk to (path to startup disk)

tell application <font color = red>"Finder"</font>
activate

set this_window to make new Finder window
set the target of this_window to the startup_disk
set the bounds of this_window to {<font color = blue>0</font>, <font color = blue>46</font>, <font color = blue>1100</font>, <font color = blue>440</font>}
set the current view of this_window to column view

set this_window to make new Finder window
set the target of this_window to the startup_disk
set the bounds of this_window to {<font color = blue>0</font>, <font color = blue>468</font>, <font color = blue>1100</font>, <font color = blue>926</font>}
set the current view of this_window to column view

end tell

</font>[/code]

What the code should do and used to do was open two Finder windows, each filling roughly the entire width and half the height of my screen, and each displaying the root level of my hard disk, Mjollnir.

Upon attempting to run this script now, a new window opens, then I get the error message 'Finder got an error: Can't set target of Finder window id ## to alias "Mjollnir:"'. The id number ## increments each time I try to run the script, but the rest of the message remains consistent.

If I comment out the "set the target..." line and try again, I get the error "Finder got an error: Can't set bounds of Finder window id ## to {0, 46, 1100, 440}".

Commenting out that line as well, I get the error "Finder got an error: Can't set current view of Finder window id ## to column view."

Any thoughts as to what's going on? I don't really know AppleScript, but it looks to me like the Finder "dictionary" still contains all of those terms, so why do they no longer work? Any help is appreciated.
"A scientist can discover a new star but he cannot make one. He would have to ask an engineer to do it for him."
     
hmpff
Junior Member
Join Date: Jul 2001
Location: Canada
Status: Offline
Reply With Quote
Apr 23, 2002, 06:21 PM
 
I'm running Mac OS 10.1.4 and I could run the script you posted (your modified version).
     
sjk
Forum Regular
Join Date: Feb 2002
Location: Hawaii
Status: Offline
Reply With Quote
Apr 23, 2002, 08:36 PM
 
Works with 10.1.4 on my iBook 600. Have you tried restarting Finder?
     
Glennfield  (op)
Junior Member
Join Date: Dec 2001
Location: My own personal purgatory
Status: Offline
Reply With Quote
Apr 24, 2002, 12:39 AM
 
Interesting - sjk, relaunching the Finder did indeed cause the script to start working again. Thanks. I know this isn't the first time this has happened to me, though - any ideas as to what brings it on?

Incidentally, I have not yet updated to 10.1.4. I'd be curious to know if anyone has experienced similar strangeness under the newer system.
"A scientist can discover a new star but he cannot make one. He would have to ask an engineer to do it for him."
     
sjk
Forum Regular
Join Date: Feb 2002
Location: Hawaii
Status: Offline
Reply With Quote
Apr 30, 2002, 05:24 AM
 
Glad that worked. I'm sure there are Finder bugs that cause it to get confused, especially when AppleScript is involved.

Strings in Finder's version.plist claims it's still at version 10.1.2 tho' it's interesting that the timestamp of the binary corresponds to when I ran the 10.1.4 update. Nothing else under /System/Library/CoreServices appears to have been touched. I can figure out most Unixish glitches, but my knowledge of Mac OS X specific internals is still pretty vague. Thankfully it's far less obscurely unpredictable than Windows, which I only have to deal with when sysadmin'ing my wife's notebook PC.

Happy to discuss any of this more through e-mail if you'd like.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:22 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,