I know nothing about Applescript except what it is capable of doing.
I am trying to automate a frequent task that I do in Appleworks 6 word processing. It is so simple that I cannot believe there isn’t a shortcut to do it.
I want to take a highlighted section of copy, make it the name of a new file, paste it into the file, and then return to the original file.
In other words:
control C
control N
control V
control S
control V
return
control ~
Can some expert write this script for me?
(It is amazing that applesot OS-X won’t record a macro, won’t record an applescript, and won’t cooperate with automator.)
sorry, I don’t have appleworks or i’d have made your script for you.
but if it follows the rules of most other apple apps GUI scripting is unnessecary and unrecommended
Is this the sort of thing? Run this after highlighting the text.
tell application "AppleWorks 6"
activate
copy to clipboard
make new document at front
paste
save document 1 in (choose file name default name (the clipboard))
close document 1
end tell
On the contrary, John. If anyone found your question amusing, I’m sure they were in a very small minority. We’re all at some point on a learning curve here, after all.
I should add that I don’t agree with the views expressed earlier about UI scripting. Sure, it’s probably best kept as a last resort but, hey - if it works, why knock it? And while John M’s approach would also be my preferred method in this situation, your initial post was already remarkably close to a working script. All it needed was a little nip’n’tuck here and there:
tell application "AppleWorks 6" to activate
tell application "System Events"
keystroke "cnvsv" using command down
keystroke return
keystroke "~" using command down
end tell
The same general technique could be used to invoke the keyboard shortcuts of any number of apps - including quite a few that may have only limited access via AppleScript. Of course, there’s no substitute for gradually getting to know AppleScript better - and checking an application’s AS dictionary for clues as to what might be possible. But when the chips are down, I wouldn’t hesitate to use anything that works…