For my research I do lot of newspaper reading and sort the clippings under relevant headings. Tideous. With a lot of effort and serarching on internet I manage to do do wonderful solution. I have a wordfile with the different headings bookmarked, and I have made an apple script for the (more then 50) different headings. Works fine, apart from that I do not manage to make the first step work: to copy the selected text in Safari to clipboard. Have tried ALL I can imagine for several days, from keystroke “C”, to get selection. Apparently I must have missed some elementary issue.
Below is some of the different variants of the start of the script that does not work. The rest of the script, that works fine for me as a beginner (but I am sure it is clumzy and could be refined) activitates the relevant document in word, past the text unformatted, jumps back to the end of the first paragraph (the headline) and assign heading 3 (which is the relevant heading in this context). But I would be greatful for assistance how to make Safari copy the highlighted text to clipboard.
- I have also tried to make a dialog box where the script takes me to a specific applescriptfolder where I could click on the relevant apple script,and then continue with the script. Which I have not mastered yet. If some one could assist me with that I would immensly grateful. (I have four main folders for political, economic, social and international issues, each with 5-10 applescripts for more specific issues).
I use OS 10.6.3 and Word 2008, in Swedish (and I start to wonder if that might be the source of the difficulties). I then assign a keyboard short cut with QuickKeys for each applescript.
Following apple script are among them I have tried and does not work:
tell application “System Events”
tell process “Safari”
keystroke “c” using {command down}
delay 2
set myData to (the clipboard) as text
end tell
tell application “System Events” to tell application process “Safari”
keystroke (ASCII character 99) using command down – Copy
delay 2
set myData to the clipboard as text
end tell
tell application “System Events”
tell process “Safari”
set frontmost to true → bring app to the foreground
click menu item 5 of menu 1 of menu bar item 4 of menu bar 1 → copy
end tell
end tell
Below script works fine and is extremely timesaving, but I liked to add the small copy thing above.
tell application “Microsoft Word”
activate
activate object document “News Tanzania 200911”
select bookmark “Politics_CCJ” of active document
type paragraph selection
tell selection
try
set theClip to Unicode text of (the clipboard as record)
type text text theClip
end try
end tell
type paragraph selection
select bookmark “Politics_CCJ” of active document
tell application “System Events” to tell application process “Microsoft Word”
keystroke (ASCII character 31) – down arrow key
keystroke (ASCII character 29) using command down – right arrow key end
end tell
tell application “Microsoft Word”
set style of selection to style heading3
end tell
end tell
Thanks!
Model: MacBook Pro
AppleScript: 2.3 (118)
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)