Welcome to MacForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

UI Scripting: why this won't work

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  [Newbie] Intermittent error opening file (using S..  
Author Message
Zephrane

External


Since: Oct 16, 2003
Posts: 19



(Msg. 1) Posted: Wed Jan 14, 2004 12:29 am
Post subject: UI Scripting: why this won't work
Archived from groups: alt>comp>lang>applescript (more info?)

I found this script on Apple 's site using UI scripting to import
pictures of a folder into iPhoto: this_item is the choosen folder.
//
-- convert the file reference to UNIX style
set this_path to the POSIX path of this_item
-- bring the target application to the front
tell application "iPhoto"
activate
try
tell application "System Events"
tell process "iPhoto"
-- summon the import dialog
click menu item "ImporterŠ" of menu "Fichier" of menu bar
1
-- enter the path to the image in the dialog input

set the value of text field 1 of group 1 of group 2 of
window "Importer des photos" to this_path

delay 1
-- click to start the import
click button "Importer" of window "Importer des photos"
if the last character of (this_item as string) is ":" then
-- it's a folder so click the import button again
click button "Importer" of window "Importer des photos"
end if
end tell
end tell
on error error_message
display dialog error_message buttons {"OK"} default button 1
end try
--
///

I've taken the same code to make a toolbar script , selecting the folder
by:
//
tell application "Finder"
activate
set this_item to (the target of the front window) as string
----
end tell
//

and then when the import window of iphoto opens the line
//set the value of text field 1 of group 1 of group 2 of window
"Importer des photos" to this_path//

returns an invalid path error!!
why?
if you try, make sure you change the names of the menus and buttons
above to english system.

*** remove "_no_junk" for mail replies ***

 >> Stay informed about: UI Scripting: why this won't work 
Back to top
Login to vote
Patrick Stadelmann

External


Since: Nov 12, 2003
Posts: 247



(Msg. 2) Posted: Wed Jan 14, 2004 2:57 am
Post subject: Re: UI Scripting: why this won't work [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
Zephrane <zephrane.DeleteThis@free_no_junk.fr> wrote:

You forgot to convert the Macintosh-style path returned by the Finder to
a POSIX-style path (required by the open dialog) as specified on top of
Apple's script :

 > -- convert the file reference to UNIX style
 > set this_path to the POSIX path of this_item

Patrick
--
Patrick Stadelmann

 >> Stay informed about: UI Scripting: why this won't work 
Back to top
Login to vote
Zephrane

External


Since: Oct 16, 2003
Posts: 19



(Msg. 3) Posted: Thu Jan 15, 2004 2:27 am
Post subject: Re: UI Scripting: why this won't work [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I
Actually, though I didn't put it in the pasted code in the message, I
did not forget this important line



n article
,
Patrick Stadelmann <Patrick.Stadelmann.DeleteThis@unine.ch> wrote:

 > You forgot to convert the Macintosh-style path returned by the Finder to
 > a POSIX-style path (required by the open dialog) as specified on top of
 > Apple's script :




--
*** remove "_no_junk" for mail replies ***
 >> Stay informed about: UI Scripting: why this won't work 
Back to top
Login to vote
Patrick Stadelmann

External


Since: Nov 12, 2003
Posts: 247



(Msg. 4) Posted: Thu Jan 15, 2004 3:30 am
Post subject: Re: UI Scripting: why this won't work [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article ,
Zephrane <zephrane RemoveThis @free_no_junk.fr> wrote:

 > I
 > Actually, though I didn't put it in the pasted code in the message, I
 > did not forget this important line

Turn on the Event Log and make sure that the string entered in the
"Import" dialog is correct (compare it to the one in Apple's scritp).
Also, try pasting it manually in the "Import" dialog.

Patrick
--
Patrick Stadelmann
 >> Stay informed about: UI Scripting: why this won't work 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
UI Scripting: Does it work? - Hello, I always get the strangest results when I try to script "System Events". For example: ------------------------------------ tell application "System Events" tell menu bar 1 of process "Finder" click menu...

Scripting RealPlayer 10 - Is it possible to instruct Real Player to open a specific URL? I've tried a few different things, and the best I can do is to get RealPlayer to start up. Can't get it to recognize the URL... tell application "RealPlayer" open..

Getting info from UI Scripting - How can I get information using UI scripting? For example, let's say I want to do one thing if speakers are plugged, another if they're not. This info is apparently available to the UI Scripting inspector, because I can get a panel that shows: ...

UI Scripting Beta -

Need help scripting TextEdit - I use TextEdit to keep a logbook, and I have a fairly simple script to open TextEdit and to create a time stamp (see script below). After the script runs, I have to scroll down to the end of the document and paste the timestamp. I want the timestamp to....
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]