Le 25 févr. 2006, à 10:48, Christian Vinaa a écrit :
on open
tell application "Finder"
set TheList to selection
end tell
repeat with x in TheList
tell application "Preview"
open x
set myResult to display dialog "Keep or delete picture ?" buttons
{"Keep", "Delete"} default button 2 with icon note
set buttonAnswer to button returned of myResult
if buttonAnswer is "Keep" then
tell application "System Events"
tell process "Preview"
click menu item "Luk" of menu "Arkiv" of menu bar 1
--type "w" holding command
end tell
end tell
else if buttonAnswer is "Delete" then
tell application "Finder"
set label index of x to 7
end tell
tell application "System Events"
tell process "Preview"
click menu item "Luk" of menu "Arkiv" of menu bar 1
--type "w" holding command
end tell
end tell
end if
end tell
end repeat
end open
Thanks Christian but your code is version specific.
I don't know the english wording but in french,
Luk = Fermer
Arkiv = Fichier
So the script must be changed for every localised version.
It is easy to edit it to give an universal code:
on open
tell application "Finder"
set TheList to selection
end tell
repeat with x in TheList
tell application "Preview"
open x
set myResult to display dialog "Keep or delete picture ?" buttons
{"Keep", "Delete"} default button 2 with icon note
set buttonAnswer to button returned of myResult
if buttonAnswer is "Keep" then
tell application "System Events"
tell process "Preview"
--click menu item "Luk" of menu "Arkiv" of menu bar 1 (* version
specific *)
keystroke "w" using {command down} (* universal *)
end tell
end tell
else if buttonAnswer is "Delete" then
tell application "Finder"
set label index of x to 7
end tell
tell application "System Events"
tell process "Preview"
--click menu item "Luk" of menu "Arkiv" of menu bar 1 (* version
specific *)
keystroke "w" using {command down} (* universal *)
end tell
end tell
end if
end tell -- application "Preview"
end repeat
end open
which may be shorten as:
on open
tell application "Finder"
set TheList to selection
end tell
repeat with x in TheList
tell application "Preview"
open x
set myResult to display dialog "Keep or delete picture ?" buttons
{"Keep", "Delete"} default button 2 with icon note
set buttonAnswer to button returned of myResult
if buttonAnswer is "Delete" then
tell application "Finder"
set label index of x to 7
end tell -- Finder
end if
tell application "System Events"
tell process "Preview"
--click menu item "Luk" of menu "Arkiv" of menu bar 1 (* version
specific *)
keystroke "w" using {command down} (* universal *)
end tell -- process "Preview"
end tell -- System Events
end tell -- application "Preview"
end repeat
end open