Re: Attivating the display dialog window
Re: Attivating the display dialog window
- Subject: Re: Attivating the display dialog window
- From: dev_sleidy <email@hidden>
- Date: Tue, 11 Jul 2006 07:29:40 -0400
I'm afraid Preview is not scriptable and do not accept commands.
'Preview' can handle the AppleScript 'Required Suite' of 'run'
(although most will use 'activate'), 'open', 'print', and 'quit';
thus, the reason for the code supplied yesterday.
I think activate is not a standard command and is not executed by Preview.
'run' or 'activate' work correctly in launching (running, opening) 'Preview'.
I've moved activate out of the tell Finder, so the target of display
is my script. This because activate opens also the Finder window.
The dialog window is ok now but it happens a strange fact: some
fotos opens, some no. I cannot get why. I used a delay at the end.
Yet, you have not provided the code for public review, and suggestions.
I open the foto, I display the dialog, I change the name and close
Preview. I thought that maybe the foto is closed before it opens. I
don't know. It seems it works.
Still - with no code posted ...
I have to test better!
Only you?!
-----
In the code below, you can substitute 'Safari' with the names of
other web browsers - such as 'Camino', 'Firefox', and 'Shiira'; or,
graphic applications - such as 'GraphicConverter'. Other
applications will require modification of the code.
Use 'Google' ('<http://www.google.com>') or 'Version Tracker'
('<http://www.versiontracker.com>') to locate and obtain such
applications.
on open (the_Items) -- Handle items dragged onto this applet.
my handle_items(the_Items)
end open
-- Handler (function) to process selected items.
on handle_items(local_Items)
tell application "Safari" -- If not already, launch (run, open) 'Safari'.
activate
if (window 1 exists) then close window 1 -- Optional, close any
window opened by default.
end tell
repeat with i in local_Items -- Cycle through the selected items.
if (not ((info for file (i as string)) is folder)) then -- Process
only file(s), not folder(s).
tell application "Safari" to open i -- Open a file.
my rename_file(i) -- Handle renaming file, via a handler (function).
tell application "Safari" to close window 1 -- Optional, close
each window, after possible file name change.
end if
end repeat
tell application "Safari" to quit -- Optional, quit 'Safari'.
end handle_items
-- Hander (function) to 'rename' file.
on rename_file(local_i)
tell application "Finder" to set {file_Name, file_path} to
{displayed name of local_i, container of local_i}
tell me
activate
set tResult to (text returned of (display dialog ("Rename file: " &
file_path) default answer file_Name))
end tell
try -- Attempt to rename the file.
if (tResult is not equal to file_Name) then tell application
"Finder" to set name of file (local_i as string) to tResult
on error
my rename_file(local_i) -- 'Finder' errors handled.
end try
end rename_file
_______________________________________________
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