Re: How to close finder window
Re: How to close finder window
- Subject: Re: How to close finder window
- From: Mark Pauley <email@hidden>
- Date: Thu, 2 Jun 2005 17:05:24 -0700
AppleScripts don't really know they can be run with arguments...
But we're geeks and we want/need this stuff to happen.
I have done this before by using AppleScript in a here-document in perl:
***
#! /usr/bin/perl -w
$windowName = $ARGV[0];
my $appleScript = <<"END_S";
tell application "Finder"
set theWindows to (get every Finder window)
repeat with eachWindow in theWindows
if (target of eachWindow as text) begins with
"$windowName" then
close eachWindow
end if
end repeat
end tell
END_S
my $returnVal;
chomp($returnVal = `osascript -ss -e '$appleScript'`);
print $returnVal, "\n";
***
Bammo, close windows from the terminal!
Unfortunately this requires forking a new process. I would recommend
looking into using AppleEvents to do something like this, AppleScript
is just an easy way to send AppleEvents.
_Mark
On Jun 2, 2005, at 3:34 AM, David Siberry wrote:
I have written a script that closes the finder window. However i dont
want the variable to be static, I want to be able to input this
variable dynamically via C or C++.
The script so far is:
tell application "Finder"
set theWindows to (get every Finder window)
repeat with eachWindow in theWindows
if (target of eachWindow as text) begins with "Mac OS X:" then
close eachWindow
end if
end repeat
end tell
I want the "Mac OS X" bit to be dynamic. Perhaps using a "\%s\"
But i dont know in C how to obtain the path of the window.
Can anyone help?
Cheers
David
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
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