It's pretty easy to craft an AppleScript that can tell the Finder to
select an object:
tell application "Finder" to select (POSIX file "/Developer/
Applications/Xcode.app")
(And you might want to tell the Finder to "activate" as well, but
that wasn't originally requested...)
The tricky parts are:
- Running an AppleScript from C. If you don't mind using a tiny bit
of Objective-C, I'd highly recommend NSAppleScript for this. This
will do it all in just a few lines of code. Just Google for example
code.
- Handling non-ASCII paths... and I'll tell you the secret to that
right now:
set myPath to («data utf8DEADBEEF1234567890» as Unicode text)
Basically you need to convert the path to UTF8, then you need to
convert that UTF8 path to a hexadecimal string, and then you wrap it
all in "«data utf8…»". Weird, but that's how it is in AppleScript.
On Mar 12, 2007, at 12:31 PM, Steve Christensen wrote:
On Mar 11, 2007, at 12:57 PM, Søren Neigaard wrote:
Anyways, I would like to make a small application I can activate
with some shortcut (I will figure that part out) and then in the
currently open finder window select some specific files.
Are you trying to select the files in the Finder in the sense that
they would become highlighted? Or are you saying that, for the
active Finder window you want to, say, build a list of files given
the parent directory represented by the Finder window?
Could you guys point me in the right direction to detecting the
current open finder window, and how I select files in this window?
If you want to find out the state of the Finder and/or make
changes, you'll need to send AppleEvents to the Finder. There is
really no other programmatic interface for interacting with the
Finder.
steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/jstiles%
40blizzard.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden