What happened to "append Nisus document with selected text"

Everything related to our flagship word processor.
User avatar
martin
Official Nisus Person
Posts: 5230
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: What happened to "append Nisus document with selected te

Post by martin »

phspaelti wrote:Couldn't this be improved by sending control to a Nisus Macro, once the text has been copied?
That's a good idea. I also like Þorvarður's idea of copying text from (and reactivating) the frontmost app, instead of just assuming Safari. Here's the updated macro:

Code: Select all

set nisusMacroCode to "
	$doc = Document.active
	If ! $doc
		$doc = Document.new
	End
	
	Select Document End
	Type Newline
	Paste
"


tell application "System Events"
	set restoreAppName to item 1 of (get name of processes whose frontmost is true)
	keystroke "c" using command down
	delay 0.25
end tell

tell application "Nisus Writer Pro"
	activate
	Do Menu Macro with macro nisusMacroCode
end tell

tell application restoreAppName to activate
User avatar
martin
Official Nisus Person
Posts: 5230
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: What happened to "append Nisus document with selected te

Post by martin »

Þ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.
Post Reply