|
Related Topics:
| scripting Quicktime to convert images to jpg - Here is a droplet that I am working on to have Quicktime translate still images generated by iMovie into JPG images that can be imported into iPhoto. on open (theList) tell repeat with x in theList if
Help with script, please - Here is the script: tell set foo to the selection set foo to item 1 of foo set address_ to address of item 1 of to recipient of foo if not (name of item 1 of to recipient of foo exists) then set text..
Finder label texts - Hi, it's easy to get a file's label *number*: set f to (choose file) tell get label index of f --as text end tell But how do I get the text? By somehow reading the Finder -- Tobias Weber
Open a file in PhotoshopCS - I would open an image with photoshop and do some action. I try this 2 scripts: set the to (choose folder) as string tell set fileList to name of every file of folder as list end tell repeat with..
update applescript - I am only now practiced enough in that some anomalies in the language are bugging me. In looking for one of the first documents I read was the Apple web page listing all the bugs in version 1.9.1. I have version 1.9.1 on osx..
|
|
|
Next: Apple Scripts: script to Open PageMaker 6.5 documents
|
| Author |
Message |
External

Since: Jun 22, 2008 Posts: 11
|
(Msg. 1) Posted: Thu Jul 24, 2008 3:37 pm
Post subject: Simplification for Text-apps Archived from groups: alt>comp>lang>applescript (more info?)
|
|
|
Let's save time with my little script, where purpose is to save
Documents of Text-applications with the title as name in front window
of Finder (you can do 2 actions in one step, instead to confirm
separately 100 times which name, which path to choose)
--Test
tell application "System Events"
set x to name of every process whose frontmost is true
set x to x as text
end tell
tell application "Finder"
set y to (folder of front window) as text
set the_path to (y & "Test")
end tell
tell application x
activate application x
try
set i to window 1
on error
set i to document 1
end try
try
save i in the_path
on error the error_message number the error_number
display dialog "Error: " & the error_number & ". " &
the
error_message buttons {"Cancel"} default button 1
end try
end tell
--Unfortunately it's not functional, simple what it is. |
|
| Back to top |
|
 |  |
External

Since: Jun 22, 2008 Posts: 11
|
(Msg. 2) Posted: Sat Jul 26, 2008 4:35 am
Post subject: Re: Simplification for Text-apps [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
i've updated my script. Now works,
a) the document gets the entire name from paragraph 1
b) the document will save itself in the front window of (open finder
win or desktop, x default)
but:
c) the open front document will not recognize the path, it saves a
copy with all properties -name and contents
(is not so important, but not desired)
d) it adds no default extension to the saved copy
here the code:
--Test hh f ff
tell application "System Events"
set x to name of every process whose frontmost is true
set x to x as text
end tell
tell application "Finder"
if exists windows then
set y to (folder of front window) as text
else
set y to desktop as text
end if
end tell
tell application x
activate application x
set cl to ""
try
set p1 to (paragraph 1 of document 1 as text)
on error
set p1 to (paragraph 1 of window 1 as text)
end try
repeat with i from 1 to count words in p1
set this_word to word i of p1
if cl is "" then
set cl to this_word & space
else if cl ≠ i then
set cl to cl & this_word & space
else if cl = i then
set cl to cl & this_word
end if
end repeat
set the_path to (y & cl)
try
set name of document 1 to cl
save document 1 in the_path
on error
set name of window 1 to cl
save window 1 in the_path
end try
end tell |
|
| Back to top |
|
 |  |
External

Since: Aug 30, 2005 Posts: 804
|
(Msg. 3) Posted: Sat Jul 26, 2008 11:26 am
Post subject: Re: Simplification for Text-apps [Login to view extended thread Info.] Imported from groups: per prev. post (more info?)
|
|
|
This message is not archived |
|
| Back to top |
|
 |  |
External

Since: Jun 22, 2008 Posts: 11
|
(Msg. 4) Posted: Sun Jul 27, 2008 3:02 am
Post subject: Re: Simplification for Text-apps [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hey, M.
my script is thinked for only use with Text-applications, how
described in the first article of this post (..where purpose is to
save Documents of Text-applications with the title as name in front
window of Finder )I've see that Applescripts are always to control or
to adjust after system updates, so the results of my functional script
can be different on better of lower operation systems, it can produce
errors.
>What happens if the frontmost application is not a text application, so
>the document doesn't have any paragraphs?
Ok, you can insert a list of all text-apps where you use, before the
>tell application x
like:
----------------------
set text_apps to {"Script Editor", "TextEdit", "VoodooPad"}--ect.
if x is in text_apps then
tell application x (...)
----------------------
>What happens if there aren't
>any open windows in that application?
Ok, in this case the script tryes to execute the given commands, and
whenever results a error, the entire script stops automatically in the
try-routine.
> try
> set p1 to (paragraph 1 of document 1 as text)
> on error
> set p1 to (paragraph 1 of window 1 as text)
> end try
the next step in this script is to discover the default name extension
where uses your activ Textapp, where solves both problems:
>c) the open front document will not recognize the path, it saves a
>copy with all properties -name and contents
> (is not so important, but not desired)
>d) it adds no default extension to the saved copy
If you have a ideas? |
|
| Back to top |
|
 |  |
External

Since: Jun 22, 2008 Posts: 11
|
(Msg. 5) Posted: Tue Jul 29, 2008 6:16 am
Post subject: Re: Simplification for Text-apps [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
a little update of the script. i hope thats helpful for others too!
* now, the script searches down to 9 paragraphs for the title, if
every other paragraphs are empty, collecting all words from this
paragr. only
--Test hh f ff
tell application "System Events"
set x to name of every process whose frontmost is true
set x to x as text
end tell
tell application "Finder"
if exists windows then
set y to (folder of front window as text)
else
set y to (desktop as text)
end if
end tell
tell application x
activate application x
set cl to ""
try
set pg to document 1
on error
set pg to window 1
end try
tell pg
if pg is not "" then
set w1 to word 1 as text
set paras to {123456789} as string
repeat with i from 1 to count characters in paras
set this_word to character i of paras as number
if w1 is in paragraph this_word then
set this_word to (this_word as number)
repeat with i from 1 to count words in paragraph this_word
set this_w to word i of paragraph this_word
if cl is "" then
set cl to this_w & space
else if cl ≠ i then
set cl to cl & this_w & space
else if cl = i then
set cl to cl & this_w
end if
end repeat
--display dialog (cl as text)
end if
end repeat
set the_path to (y & cl)
try
set name of document 1 to cl
save document 1 in the_path
on error
set name of window 1 to cl
save window 1 in the_path
end try
end if
end tell
end tell |
|
| Back to top |
|
 |  |
External

Since: Jun 22, 2008 Posts: 11
|
(Msg. 6) Posted: Tue Jul 29, 2008 11:26 am
Post subject: Re: Simplification for Text-apps [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
A new update.. the script might be functional, only the save.. command
works in a second time (you must activate this script 2 times to
become the result, grunt.....)any ideas??
--Test hh f ff
tell application "System Events"
set x to name of every process whose frontmost is true
set x to x as text
end tell
tell application "Finder"
try
set y to (folder of front window) as text
on error
set y to desktop as text
end try
end tell
set text_apps to {"Script Editor", "TextEdit"} --ect.
if x is in text_apps then
tell application x
activate application x
set cl to ""
try
set pg to document 1
on error
set pg to window 1
end try
tell pg
if pg is not "" then
set w1 to word 1 as text
set paras to {123456789} as string
repeat with i from 1 to count characters in paras
set this_word to character i of paras as number
if w1 is in paragraph this_word then
set this_word to (this_word as number)
repeat with i from 1 to count words in paragraph this_word
set this_w to word i of paragraph this_word
if cl is "" then
set cl to this_w & space
else if cl ≠ i then
set cl to cl & this_w & space
else if cl = i then
set cl to cl & this_w
end if
end repeat
end if
end repeat
if x = "TextEdit" then
set the_str to "
formatted text= rtf
text and pictures= rtfd
unformatted text= txt"
set butt to {"rtf", "rtfd", "txt"}
else if x = "Script Editor" then
set the_str to "
script document= scpt
script droplet= app
script text= applescript"
set butt to {"scpt", "app", "applescript"}
end if
display dialog "in what format want you to save the document ?" &
return & the_str & return buttons butt default button 1
set xt to the button returned of the result
set the_path to (y & cl & "." & xt)
--display dialog the_path
try
set name to cl
end try
save in the_path
end if
end tell
end tell
end if |
|
| Back to top |
|
 |  |
|