Þorvarður wrote:Especially this "JavaScript" thing that suddenly pops up out of nowhere and brings the tension and suspense to a climax. I'm sure Shakespeare would go green with envy if he were still alive.
haha, well I must admit to stealing that JavaScript snippet from a google search. Honestly my AppleScript authoring skills are pretty low. But as they say, everything is a remix.
Þorvarður wrote:How can I call "System Events" at the beginning and *exclude* Nisus Writer Pro?
If you look at the macro I just posted above, you could check the "restoreAppName" and abort if Nisus Writer was frontmost.
It would be great to let the scripts grab the URL when in a web browser and enter it at the end of the pasted snippet
This is also possible. A quick google search reveals the desired AppleScript nouns:
Code: Select all
tell application "Safari"
set theURL to URL of current tab of window 1
end tell
You could work that into the inserted content however you'd like, if you detect that the active application is Safari.
If the selected text is from a PDF, then it would be good to grab the name of the PDF
If the app in question is a document-based Cocoa application, then this should work:
Code: Select all
tell application "The App"
tell front document
set theName to get name as string
end tell
end tell
However, not all apps will respond to those commands.
Þorvarður wrote:Just curious, what is it, Martin, that you don't like with AppleScript?
I do not like its attempted "natural language" syntax. I program regularly in other languages (eg: Objective-C) and AppleScript's syntax is cumbersome to me. Also its
way of co-opting regular English is confusing. I'm sure a big part of that is just because I rarely use AppleScript, but I prefer traditional, computer-science type, languages.
However, AppleScript can be very useful, so I can't be too hard on it.