Discussion:
Show me in the Finder
(too old to reply)
Emile Schwarz
2010-03-20 11:28:04 UTC
Permalink
Hi,

I know how to add a MenuItem, but I do not have the shadow of an idea of
how I can write the code to "Show this item in the Finder".

In FireFox and in so many other application, this function exists and I
now feel the need to add it in one (or two) of my projects, but I do not
know where (and how) to start.

Any idea ?

TIA,

Emile
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Markus Winter
2010-03-20 11:42:49 UTC
Permalink
Sorry - f.parent.launch



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Sven E Olsson
2010-03-20 11:57:42 UTC
Permalink
On OS X

if f <> nil and f.Exists then
dim a as AppleEvent = NewAppleEvent("misc", "slct", "MACS")
a.FolderItemParam("----") = f
If a.send then
a = NewAppleEvent("misc", "actv", "MACS")
If a.send then
//Success
Else
//Activate failed
End if
Else
//Select failed
End if

end if


Sven E
Hi,
I know how to add a MenuItem, but I do not have the shadow of an idea of how I can write the code to "Show this item in the Finder".
In FireFox and in so many other application, this function exists and I now feel the need to add it in one (or two) of my projects, but I do not know where (and how) to start.
Any idea ?
TIA,
Emile
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Maximilian Tyrtania
2010-03-20 13:02:07 UTC
Permalink
...and on windows:

dim s as shell
s=new shell
s.execute "explorer /Select, "+f.absolutePath //Per Aaron Ballman 11/8/2006

Best,

Maximilian Tyrtania Software-Entwicklung
Dessauer Str. 6-7
10969 Berlin
Tel.: ++49/30/48827-952
Mobil: 0152/292 707 36
Post by Sven E Olsson
On OS X
if f <> nil and f.Exists then
dim a as AppleEvent = NewAppleEvent("misc", "slct", "MACS")
a.FolderItemParam("----") = f
If a.send then
a = NewAppleEvent("misc", "actv", "MACS")
If a.send then
//Success
Else
//Activate failed
End if
Else
//Select failed
End if
end if
Sven E
Hi,
I know how to add a MenuItem, but I do not have the shadow of an idea of how I can write the code to "Show this item in the Finder".
In FireFox and in so many other application, this function exists and I now feel the need to add it in one (or two) of my projects, but I do not know where (and how) to start.
Any idea ?
TIA,
Emile
_______________________________________________
<http://www.realsoftware.com/support/listmanager/>
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Rubber Chicken Software Co.
2010-03-24 23:32:36 UTC
Permalink
Post by Sven E Olsson
Post by Emile Schwarz
I know how to add a MenuItem, but I do not have the shadow of an
idea of how I can write the code to "Show this item in the Finder".
On OS X
if f <> nil and f.Exists then
dim a as AppleEvent = NewAppleEvent("misc", "slct", "MACS")
a.FolderItemParam("----") = f
If a.send then
a = NewAppleEvent("misc", "actv", "MACS")
If a.send then
//Success
Else
//Activate failed
End if
Else
//Select failed
End if
end if
What about if you want to show an enclosing folder? In other words,
in the example above, "f" would be a folder (a directory), and you
want to show in "innards" of that. The example above just shows the
current folder as the enclosing one of "f" and highlights "f". I'm
more interested in OPENING f to show it's contents.

I know you could just look for an item in that folder and do the
calls around that, but isn't there a simpler way?

* * * * * * * * * * * * * * * * * * * * * * * * * * *
| Garth Hjelte |
| Customer Service Representative, President |
| Chicken Systems, Inc, Rubber Chicken Software Co. |
| 714 5th Street SE |
| Willmar, MN 56201 USA |
| |
| 800-8-PRO-EPS Toll Free Order Line (US Only) |
| 320-235-9798 Tech Support, Sampler Questions |
| International Line |
| 360-838-7689 Fax |
| Product Sales: sales-sfbgH+XYTwiU+1/***@public.gmane.org |
| Product Support: support-sfbgH+XYTwiU+1/***@public.gmane.org |
| Sampler Q+A: qa-sfbgH+XYTwiU+1/***@public.gmane.org |
| Web Page: www.chickensys.com |
* * * * * * * * * * * * * * * * * * * * * * * * * * *


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Someone
2010-03-25 01:32:16 UTC
Permalink
Post by Rubber Chicken Software Co.
Post by Sven E Olsson
Post by Emile Schwarz
I know how to add a MenuItem, but I do not have the shadow of an
idea of how I can write the code to "Show this item in the Finder".
On OS X
if f <> nil and f.Exists then
dim a as AppleEvent = NewAppleEvent("misc", "slct", "MACS")
a.FolderItemParam("----") = f
If a.send then
a = NewAppleEvent("misc", "actv", "MACS")
If a.send then
//Success
Else
//Activate failed
End if
Else
//Select failed
End if
end if
What about if you want to show an enclosing folder? In other words,
in the example above, "f" would be a folder (a directory), and you
want to show in "innards" of that. The example above just shows the
current folder as the enclosing one of "f" and highlights "f". I'm
more interested in OPENING f to show it's contents.
I know you could just look for an item in that folder and do the
calls around that, but isn't there a simpler way?
Well, normally, the FolderItem.launch method shows a folder in the
Finder (when the folderitem is a folder, of course),

Anyway, if you want the AppleEvent way, instead of selecting an item,
just open its parent:
(say f is any folderitem for which you want to open the parent folder)
dim ae as AppleEvent

ae=NewAppleEvent("aevt","odoc","MACS")
ae.folderItemParam("----")=f.parent
If ae.send then
ae=NewAppleEvent("misc", "actv", "MACS")
call ae.send
end if
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Rubber Chicken Software Co.
2010-03-25 13:38:11 UTC
Permalink
Post by Someone
Post by Rubber Chicken Software Co.
What about if you want to show an enclosing folder? In other words,
in the example above, "f" would be a folder (a directory), and you
want to show in "innards" of that. The example above just shows the
current folder as the enclosing one of "f" and highlights "f". I'm
more interested in OPENING f to show it's contents.
I know you could just look for an item in that folder and do the
calls around that, but isn't there a simpler way?
Well, normally, the FolderItem.launch method shows a folder in the
Finder (when the folderitem is a folder, of course),
Anyway, if you want the AppleEvent way, instead of selecting an item,
(say f is any folderitem for which you want to open the parent folder)
dim ae as AppleEvent
ae=NewAppleEvent("aevt","odoc","MACS")
ae.folderItemParam("----")=f.parent
If ae.send then
ae=NewAppleEvent("misc", "actv", "MACS")
call ae.send
end if
No, the problem is that I don't know the internal folderitem, just
the folderitem of the folder itself (read the question again).

It's like what RB does after an application build, only I don't know
the internal object within the folder. I just want the folder opened
and you see the contents, and preferably NOTHING selected.

* * * * * * * * * * * * * * * * * * * * * * * * * * *
| Garth Hjelte |
| Customer Service Representative, President |
| Chicken Systems, Inc, Rubber Chicken Software Co. |
| 714 5th Street SE |
| Willmar, MN 56201 USA |
| |
| 800-8-PRO-EPS Toll Free Order Line (US Only) |
| 320-235-9798 Tech Support, Sampler Questions |
| International Line |
| 360-838-7689 Fax |
| Product Sales: sales-sfbgH+XYTwiU+1/***@public.gmane.org |
| Product Support: support-sfbgH+XYTwiU+1/***@public.gmane.org |
| Sampler Q+A: qa-sfbgH+XYTwiU+1/***@public.gmane.org |
| Web Page: www.chickensys.com |
* * * * * * * * * * * * * * * * * * * * * * * * * * *


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Someone
2010-03-25 19:21:20 UTC
Permalink
Post by Rubber Chicken Software Co.
Post by Someone
Post by Rubber Chicken Software Co.
What about if you want to show an enclosing folder? In other words,
in the example above, "f" would be a folder (a directory), and you
want to show in "innards" of that. The example above just shows the
current folder as the enclosing one of "f" and highlights "f". I'm
more interested in OPENING f to show it's contents.
I know you could just look for an item in that folder and do the
calls around that, but isn't there a simpler way?
Well, normally, the FolderItem.launch method shows a folder in the
Finder (when the folderitem is a folder, of course),
Anyway, if you want the AppleEvent way, instead of selecting an item,
(say f is any folderitem for which you want to open the parent folder)
dim ae as AppleEvent
ae=NewAppleEvent("aevt","odoc","MACS")
ae.folderItemParam("----")=f.parent
If ae.send then
ae=NewAppleEvent("misc", "actv", "MACS")
call ae.send
end if
No, the problem is that I don't know the internal folderitem, just
the folderitem of the folder itself (read the question again).
Well, then just open the folder you know using the code above. How
would you like the Finder which file to select if you don't know
yourself? Just open the folder, passing the folder you have and it
will be shown in the Finder.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Charles Yeomans
2010-03-25 02:15:27 UTC
Permalink
Post by Rubber Chicken Software Co.
Post by Sven E Olsson
Post by Emile Schwarz
I know how to add a MenuItem, but I do not have the shadow of an
idea of how I can write the code to "Show this item in the Finder".
On OS X
if f <> nil and f.Exists then
dim a as AppleEvent = NewAppleEvent("misc", "slct", "MACS")
a.FolderItemParam("----") = f
If a.send then
a = NewAppleEvent("misc", "actv", "MACS")
If a.send then
//Success
Else
//Activate failed
End if
Else
//Select failed
End if
end if
What about if you want to show an enclosing folder? In other words,
in the example above, "f" would be a folder (a directory), and you
want to show in "innards" of that. The example above just shows the
current folder as the enclosing one of "f" and highlights "f". I'm
more interested in OPENING f to show it's contents.
I know you could just look for an item in that folder and do the
calls around that, but isn't there a simpler way?
I think this does what you want.

dim ae as new AppleEvent("aevt", "odoc", "com.apple.finder")
ae.FolderItemParam("----") = aFolder
dim b as Boolean = ae.Send


Charles Yeomans





_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Rubber Chicken Software Co.
2010-03-25 13:35:00 UTC
Permalink
Post by Charles Yeomans
Post by Rubber Chicken Software Co.
Post by Emile Schwarz
I know how to add a MenuItem, but I do not have the shadow of an
idea of how I can write the code to "Show this item in the Finder".
What about if you want to show an enclosing folder? In other words,
in the example above, "f" would be a folder (a directory), and you
want to show in "innards" of that. The example above just shows the
current folder as the enclosing one of "f" and highlights "f". I'm
more interested in OPENING f to show it's contents.
I know you could just look for an item in that folder and do the
calls around that, but isn't there a simpler way?
I think this does what you want.
dim ae as new AppleEvent("aevt", "odoc", "com.apple.finder")
ae.FolderItemParam("----") = aFolder
dim b as Boolean = ae.Send
Nope, didn't work.

* * * * * * * * * * * * * * * * * * * * * * * * * * *
| Garth Hjelte |
| Customer Service Representative, President |
| Chicken Systems, Inc, Rubber Chicken Software Co. |
| 714 5th Street SE |
| Willmar, MN 56201 USA |
| |
| 800-8-PRO-EPS Toll Free Order Line (US Only) |
| 320-235-9798 Tech Support, Sampler Questions |
| International Line |
| 360-838-7689 Fax |
| Product Sales: sales-sfbgH+XYTwiU+1/***@public.gmane.org |
| Product Support: support-sfbgH+XYTwiU+1/***@public.gmane.org |
| Sampler Q+A: qa-sfbgH+XYTwiU+1/***@public.gmane.org |
| Web Page: www.chickensys.com |
* * * * * * * * * * * * * * * * * * * * * * * * * * *


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Charles Yeomans
2010-03-25 14:40:29 UTC
Permalink
Post by Rubber Chicken Software Co.
Post by Emile Schwarz
Post by Rubber Chicken Software Co.
Post by Emile Schwarz
I know how to add a MenuItem, but I do not have the shadow of an
idea of how I can write the code to "Show this item in the
Finder".
Post by Rubber Chicken Software Co.
What about if you want to show an enclosing folder? In other words,
in the example above, "f" would be a folder (a directory), and you
want to show in "innards" of that. The example above just shows the
current folder as the enclosing one of "f" and highlights "f". I'm
more interested in OPENING f to show it's contents.
I know you could just look for an item in that folder and do the
calls around that, but isn't there a simpler way?
I think this does what you want.
dim ae as new AppleEvent("aevt", "odoc", "com.apple.finder")
ae.FolderItemParam("----") = aFolder
dim b as Boolean = ae.Send
Nope, didn't work.
Hmm; it worked for me. The folder was not opened in your test?

Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Michael Diehr
2010-03-25 18:57:41 UTC
Permalink
Post by Charles Yeomans
Post by Rubber Chicken Software Co.
Post by Charles Yeomans
I think this does what you want.
dim ae as new AppleEvent("aevt", "odoc", "com.apple.finder")
ae.FolderItemParam("----") = aFolder
dim b as Boolean = ae.Send
Nope, didn't work.
Hmm; it worked for me. The folder was not opened in your test?
I'm doing something similar, and my users complain that it occasionally doesn't work. If you test it, however, it almost always works fine in a one-time use.

Sometimes you can do this a few times and nothing happens -- I've tried variations of 'mvis' 'slct' etc, but nothing seems consistent.

I'm almost wondering if perhaps it's an OS X bug? Maybe if the folder / file is already selected or visible in any finder window, then the applescript fails (or appears to fail since it doesn't open a new window?)



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Eric dLR
2010-03-25 23:06:00 UTC
Permalink
Post by Michael Diehr
I'm doing something similar, and my users complain that it
occasionally doesn't work.
Are your users using Spaces?

Eric.



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Michael Diehr
2010-03-26 16:47:16 UTC
Permalink
Post by Eric dLR
Post by Michael Diehr
I'm doing something similar, and my users complain that it occasionally doesn't work.
Are your users using Spaces?
Eric.
Not sure. On my test system, i do have 2 spaces pages enabled (1 and 2) but I never use the 2nd one. Any know issues with Spaces?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Charles Yeomans
2010-03-26 16:59:43 UTC
Permalink
Post by Michael Diehr
Post by Eric dLR
Post by Michael Diehr
I'm doing something similar, and my users complain that it
occasionally doesn't work.
Are your users using Spaces?
Eric.
Not sure. On my test system, i do have 2 spaces pages enabled (1
and 2) but I never use the 2nd one. Any know issues with Spaces?
The main Rb issue is that developers forget to set the bundle
identifier in their apps, which causes problems with Spaces (and other
Mac OS functionality).

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Metsis
2010-03-26 11:25:50 UTC
Permalink
Post by Michael Diehr
Maybe if the folder / file is already selected or visible in any finder window, then the applescript fails (or appears to fail since it doesn't open a new window?)
At least Dock works so, i.e. if you have a window open in Finder with that
item's folder then Show in Finder in Dock item's contextual menu will bring the
last opened such window into front and select the item. Only if there is no such
window will Finder open a new one. No reason to believe AppleEvent would do
otherwise.

Just my...

Metsis

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Someone
2010-03-26 12:12:23 UTC
Permalink
Post by Metsis
Post by Michael Diehr
Maybe if the folder / file is already selected or visible in any
finder window, then the applescript fails (or appears to fail since
it doesn't open a new window?)
At least Dock works so, i.e. if you have a window open in Finder
with that item's folder then Show in Finder in Dock item's
contextual menu will bring the last opened such window into front
and select the item. Only if there is no such window will Finder
open a new one. No reason to believe AppleEvent would do otherwise.
Just my...
I believe the Dock uses AppleEvents, so I think you're right.
(anway, if the Dock didn't used AppleEvents, that would be an
"undocumented hack" and there is generally not in such cases; Apple
tend to use what's already available, except for the Dock-n-Trash ;-) ).
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Rubber Chicken Software Co.
2010-03-26 13:23:04 UTC
Permalink
Post by Charles Yeomans
Post by Rubber Chicken Software Co.
Post by Emile Schwarz
Post by Rubber Chicken Software Co.
Post by Emile Schwarz
I know how to add a MenuItem, but I do not have the shadow of an
idea of how I can write the code to "Show this item in the
Finder".
Post by Rubber Chicken Software Co.
What about if you want to show an enclosing folder? In other words,
in the example above, "f" would be a folder (a directory), and you
want to show in "innards" of that. The example above just shows the
current folder as the enclosing one of "f" and highlights "f". I'm
more interested in OPENING f to show it's contents.
I know you could just look for an item in that folder and do the
calls around that, but isn't there a simpler way?
I think this does what you want.
dim ae as new AppleEvent("aevt", "odoc", "com.apple.finder")
ae.FolderItemParam("----") = aFolder
dim b as Boolean = ae.Send
Nope, didn't work.
Hmm; it worked for me. The folder was not opened in your test?
Charles Yeomans
_______________________________________________
<http://www.realsoftware.com/support/listmanager/>
<http://support.realsoftware.com/listarchives/lists.html>
* * * * * * * * * * * * * * * * * * * * * * * * * * *
| Garth Hjelte |
| Customer Service Representative, President |
| Chicken Systems, Inc, Rubber Chicken Software Co. |
| 714 5th Street SE |
| Willmar, MN 56201 USA |
| |
| 800-8-PRO-EPS Toll Free Order Line (US Only) |
| 320-235-9798 Tech Support, Sampler Questions |
| International Line |
| 360-838-7689 Fax |
| Product Sales: sales-sfbgH+XYTwiU+1/***@public.gmane.org |
| Product Support: support-sfbgH+XYTwiU+1/***@public.gmane.org |
| Sampler Q+A: qa-sfbgH+XYTwiU+1/***@public.gmane.org |
| Web Page: www.chickensys.com |
* * * * * * * * * * * * * * * * * * * * * * * * * * *


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Christian Schmitz
2010-03-20 13:44:50 UTC
Permalink
Hi,
I know how to add a MenuItem, but I do not have the shadow of an idea of how I can write the code to "Show this item in the Finder".
In FireFox and in so many other application, this function exists and I now feel the need to add it in one (or two) of my projects, but I do not know where (and how) to start.
Any idea ?
dim f as FolderItem

f=SpecialFolder.Desktop.Child("test.txt")

if NSWorkspaceMBS.selectFile(f) then
MsgBox "Ok"
else
MsgBox "failed"
end if

Greetings
Christian
--
Read our blog about news on our plugins:

http://www.mbsplugins.de/


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Lars Jensen
2010-03-20 15:51:47 UTC
Permalink
Here's my version:

Sub ShowExternally(extends f as FolderItem)
// Exposes and selects the indicated item in Windows Explorer
// or Mac Finder.

if f.Exists then

#if TargetWin32 then

dim s as new shell
s.execute "explorer /Select, " + f.absolutePath // AaronB 11/8/2006

#elseif TargetMacOS

dim ae as AppleEvent

ae = NewAppleEvent("misc","actv","MACS") // make visible
ae.FolderItemParam("----") = f

if ae.Send then

ae = NewAppleEvent("misc","slct","MACS") // JoeH
ae.FolderItemParam("----") = f

if not ae.Send then 'note: can return false

end if

else

end if

#elseif TargetLinux

// do nothing, throw an exception...

#endif

end if

End Sub


lj

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Someone
2010-03-20 16:22:10 UTC
Permalink
Post by Lars Jensen
dim ae as AppleEvent
ae = NewAppleEvent("misc","actv","MACS") // make visible
ae.FolderItemParam("----") = f
Well, you don't have to pass any parameter to the "activate" event, so
you can remove the ae.FolderItemParam above.
Post by Lars Jensen
if ae.Send then
ae = NewAppleEvent("misc","slct","MACS") // JoeH
"mis","mvis","MACS" should also work. Perhaps you can post the
difference between both? (I haven't time to launch RB at the moment,
and I'm wondering what's the behaviour difference between "Select" and
"Make visible")
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Lars Jensen
2010-03-20 17:06:24 UTC
Permalink
    ae = NewAppleEvent("misc","actv","MACS") // make visible
    ae.FolderItemParam("----") = f
Well, you don't have to pass any parameter to the "activate" event, so you
can remove the ae.FolderItemParam above.
Thanks for the info, I'll try that out.
      ae = NewAppleEvent("misc","slct","MACS") // JoeH
"mis","mvis","MACS" should also work. Perhaps you can post the difference
between both? (I haven't time to launch RB at the moment, and I'm wondering
what's the behaviour difference between "Select" and "Make visible")
I would guess that "make visible" opens the enclosing folder and
scrolls to the item, while "Select" selects it in addition to that.
I'm not able to experiment at the moment, and I don't know a lot about
AppleEvents anyway (until your note I didn't even know that "mvis"
meant "make visible"), so don't quote me...

lj

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Someone
2010-03-20 17:11:49 UTC
Permalink
Post by Lars Jensen
Post by Lars Jensen
ae = NewAppleEvent("misc","actv","MACS") // make visible
ae.FolderItemParam("----") = f
Well, you don't have to pass any parameter to the "activate" event, so you
can remove the ae.FolderItemParam above.
Thanks for the info, I'll try that out.
You're welcome.
Well, the "actv" event (activate) means to bring the target app to the
front. It'd not make much sense to have a parameter for that ;-)
Post by Lars Jensen
Post by Lars Jensen
ae = NewAppleEvent("misc","slct","MACS") // JoeH
"mis","mvis","MACS" should also work. Perhaps you can post the difference
between both? (I haven't time to launch RB at the moment, and I'm wondering
what's the behaviour difference between "Select" and "Make visible")
I would guess that "make visible" opens the enclosing folder and
scrolls to the item, while "Select" selects it in addition to that.
I'm not able to experiment at the moment, and I don't know a lot about
AppleEvents anyway (until your note I didn't even know that "mvis"
meant "make visible"), so don't quote me...
Hmm… I admit I haven't used the "mvis" apple event since a long time
(this isn't something someone does very often), but I actually think
it selects the file as well.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Someone
2010-03-23 12:49:20 UTC
Permalink
Post by Lars Jensen
I would guess that "make visible" opens the enclosing folder and
scrolls to the item, while "Select" selects it in addition to that.
I'm not able to experiment at the moment, and I don't know a lot about
AppleEvents anyway (until your note I didn't even know that "mvis"
meant "make visible"), so don't quote me...
Well, all that interested me, so I tried to find a difference between
the "misc","mvis" and "misc","slct" calls.
I tried with various kind of folderitems:
-Volume(0)
-A file in my trash (~/.trash/MyFile)
-A file in a bundle (/Applications/iTunes/Contents/info.plist)
-An alias (both using Child and TrueChild, while I know it won't make
any difference: the file is targeted before the event is sent)
-A “regular” file
-An invisible file (/Applications/.DS_Store)
-A file that does not exist
(if someone has another idea to try, let me know).

The result: (fingers crossed :-P ) They really seem equals. I also
checked the returned values (perhaps an error code or such for an
invisible or inexistant file: no, same values returned (almost all
with nul values)).

I also wanted to add: "mvis", as mentioned earlier, stands for "make
visible", but the AppleScript command is actually "Reveal" (if you say
Tell application "Finder" to make visible startup disk, it won't work,
but replace "make visible" by "reveal" and you're set!)
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Someone
2010-03-27 17:45:56 UTC
Permalink
Hello Emile,

It seems you have responded to the french mailing list to a thread
started in the english one (still, writing in french).
Anyway, I already know your point: the “activate” appleevent “may”
take an additional parameter, however, and that is my point, this
parameter is clearly optional! The “activate” command is system-wide
(it's not the Finder that has the “Activate” command for any process:
you don't say “Tell Application “Finder” to activate application
"Mail"”, and it wouldn't make sense, for this command, to provide a
parameter of type “file” (especially to just bring an app to the front).

I haven't checked it yet, but I guess the Finder has its own
“Activate” command. Where have you looked at the “Activate” command
you mention in your answer (BTW)?

I still don't understand why it hasn't worked for you. It has worked
for others in this list (including me), so it seems to be something
happening to your side.
Bonjour,
je ne vais pas vérifier, je dis juste que le code qui nous a été
présenté marche que s'il y a un paramètre (FolderItem).
J'ai simplement mis en commentaire la ligne "dite inutile" et
exécuté le code: je n'ai pas eu "Show me in the Finder" (rien ne
s'est passé).
Lorsque j'ai enlevé le caractère commentaire, j'ai eu le droit de
voir le fichier demandé.
En fait, le petit bout du dictionaire du Finder (Snow Leopard, mais
c'était déjà le cas avant) montre bien qu'il doit y avoir un
paramètre.
Cela étant, j'ai une fonction qui marche, je ne vais pas chercher
ailleurs (sauf sous Windows lorsque j'aurais le temps de vérifier le
code passé).
Aussi: il se peut qu’il y ait un autre...
OUI, il y a un autre "activate": il permet d'activer une application
(faire passer une application au premier plan).
Dans "Éditeur AppleScript", on peut revenir à l'application "Éditeur
tell me to activate
Et ce activate là n'a pas de paramètre!
Ce que je fais n'est pas d'activer le Finder, mais de faire
apparaître un élément du Finder: le Finder est affiché et le dossier
contenant cet élément est ouvert, l'élément est sélectionné.
Deux fonctions distinctes, mais avec quelques similarités (comme
Dupond et Dupont ?).
Emile
[first mail]
removing the line: [ae.FolderItemParam("----") = f] makes the code
to fail.
activate?v : Activate the specified window (or the Finder)
activate [specifier] : the window to activate (if not specified,
activates the Finder)
On what OS have you tried that? Linux maybe?
activate [specifier] : the window to activate (if not specified,
activates the Finder)
Where [specifier] is, since surrounded by brackets, optional. You can
Tell application "Finder" to activate
just works (well, not tested under 10.6, but have they really
deprecated the "activate" command without parameters? Would not make
sense).
So, yes, aFolderItemParam _is_ mandatory.
Tell me the result of what I said above
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Emile Schwarz
2010-03-30 12:13:42 UTC
Permalink
Date: Sat, 27 Mar 2010 18:45:56 +0100
Subject: Re: Show me in the Finder
Content-Type: text/plain; charset=WINDOWS-1252; format=flowed;
delsp=yes
Hello Emile,
It seems you have responded to the french mailing list to a thread
started in the english one (still, writing in french).
No, I send a direct answer to you. I am no more in the French list (I
was removed by the French RS) and I never go back.
Anyway, I already know your point: the ?activate? appleevent ?may?
take an additional parameter, however, and that is my point, this
parameter is clearly optional! The ?activate? command is system-wide
you don't say ?Tell Application ?Finder? to activate application
"Mail"?, and it wouldn't make sense, for this command, to provide a
parameter of type ?file? (especially to just bring an app to the front).
That activate command (with a parameter) came from the Finder.

dim a as AppleEvent = NewAppleEvent("misc", "slct", "MACS")
a = NewAppleEvent("misc", "actv", "MACS")

"MACS" is the creator type of the Finder application.

IMHO: the translation can be
'use the select function from the miscellaneous set of commands of the
Finder'
'use the activate function from the miscellaneous set of commands of the
Finder'
I haven't checked it yet, but I guess the Finder has its own
?Activate? command. Where have you looked at the ?Activate? command
you mention in your answer (BTW)?
Run the AppleScript Editor, in the File menu select Open a dictionary
and choose Finder. Then search activate and you are done. That is why I
talked about _two_ activate commands! The one I use came from the Finder.
I still don't understand why it hasn't worked for you. It has worked
for others in this list (including me), so it seems to be something
happening to your side.
It worked for me only if I pass a FolderItem:

It opens the FolderItem.Parent and select (highlight) the passed FolderItem…

NOTA: the example project I use ask for a Directory and fills a ListBox
with its contents (troubles can appears if the Directory is empty).
Then, a Control-Click (right-click) in an entry of the ListBox let me
choose the "Show me in the Finder" item.

I just read the old digests and I discover potential troubles. Because I
do not have yet integrated the shared code, I cannot talk any further
about how it works for me. In my target project, the object to "Show in
the Finder" is a Directory, so I may not have troubles with non
Directories items… I do not know. All I want to do is let the user see
the ListBox selected entry in the Finder. (s)he can do what (s)he want
starting from there (in a > 800 directories / ListBox entries).


Of course, I can be wrong (but as far as I can see, if it works the way
I want...).

Regards,

Emile

MacBook 2.4GHz, UniBody, 2008-11
MacOS X 10.6.2 [now 10.6.3]

But I have a ton of troubles when I use the Finder (and some in the
REALbasic IDE).
--
J'ai levé un lièvre...

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Someone
2010-03-31 10:20:42 UTC
Permalink
Post by Emile Schwarz
Date: Sat, 27 Mar 2010 18:45:56 +0100
Subject: Re: Show me in the Finder
Content-Type: text/plain; charset=WINDOWS-1252; format=flowed;
delsp=yes
Hello Emile,
It seems you have responded to the french mailing list to a thread
started in the english one (still, writing in french).
No, I send a direct answer to you. I am no more in the French list
(I was removed by the French RS) and I never go back.
Oops… Please accept all my apologizes then (especially since I
responded in the english list to your "private" mail).
As for the French list, I'm also no longer responding to mails I see,
because of "similar" reasons.
Post by Emile Schwarz
Anyway, I already know your point: the ?activate? appleevent ?may?
take an additional parameter, however, and that is my point, this
parameter is clearly optional! The ?activate? command is system-wide
you don't say ?Tell Application ?Finder? to activate application
"Mail"?, and it wouldn't make sense, for this command, to provide a
parameter of type ?file? (especially to just bring an app to the front).
That activate command (with a parameter) came from the Finder.
dim a as AppleEvent = NewAppleEvent("misc", "slct", "MACS")
a = NewAppleEvent("misc", "actv", "MACS")
"MACS" is the creator type of the Finder application.
Well, I know that, but it does not say from which “Dictionary” it
comes. For instance, the “Display Dialog” command is in the “Standard
Additions” dictionary, but you can send the event to the Finder and it
will show the dialog (that's a point of AppleScript/AppleEvents). I
suspect there are two distinct “Activate” commands (one in the Finder,
and one global to the Core AppleScript (I don't know where that
dictionary is).
Post by Emile Schwarz
IMHO: the translation can be
'use the select function from the miscellaneous set of commands of
the Finder'
'use the activate function from the miscellaneous set of commands of
the Finder'
I guess you're right here.
Post by Emile Schwarz
I haven't checked it yet, but I guess the Finder has its own
?Activate? command. Where have you looked at the ?Activate? command
you mention in your answer (BTW)?
Run the AppleScript Editor, in the File menu select Open a
dictionary and choose Finder. Then search activate and you are done.
That is why I talked about _two_ activate commands! The one I use
came from the Finder.
Ah, it seems we agree together ;-)
Post by Emile Schwarz
I still don't understand why it hasn't worked for you. It has worked
for others in this list (including me), so it seems to be something
happening to your side.
I meant; I wonder why it hasn't worked for you to not pass a
folderitem, while others on this list (including me) have successfully
activated the Finder without passing a folderitem.
Post by Emile Schwarz
It opens the FolderItem.Parent and select (highlight) the passed FolderItem…
NOTA: the example project I use ask for a Directory and fills a
ListBox with its contents (troubles can appears if the Directory is
empty). Then, a Control-Click (right-click) in an entry of the
ListBox let me choose the "Show me in the Finder" item.
I just read the old digests and I discover potential troubles.
Because I do not have yet integrated the shared code, I cannot talk
any further about how it works for me. In my target project, the
object to "Show in the Finder" is a Directory, so I may not have
troubles with non Directories items… I do not know. All I want to do
is let the user see the ListBox selected entry in the Finder. (s)he
can do what (s)he want starting from there (in a > 800 directories /
ListBox entries).
Of course, I can be wrong (but as far as I can see, if it works the
way I want...).
That's indeed the most important thing ;-)

Regards
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Loading...