Paste without Crash (AppleScript)

Everything related to our flagship word processor.
Post Reply
hatchmo
Posts: 99
Joined: 2004-03-01 10:35:56
Location: Cotati, CA

Paste without Crash (AppleScript)

Post by hatchmo »

As Nisus Writer Pro continues to crash when pasting content that has been copied from certain websites (especially threaded ones such as Twitter, Nextdoor, etc.), I have scripted a simple workaround. Just copy the content you want, and then run this little AppleScript. It will paste the clipboard contents into a blank Apple Pages document instead of into Nisus Writer Pro. It then copies the content from Pages to a new Nisus document. No crash. Tip: If you paste these lines into a new Scripting Shortcut, you can turn it into a simple menu item or a Stream Deck button.

tell application "Pages"
activate
make new document with properties {document template:template "Blank"}
tell application "System Events"
tell process "Pages"
key code 9 using {command down} -- paste
delay 1
key code 0 using {command down} -- select all
delay 1
key code 7 using {command down} -- copy
delay 1
end tell
end tell
end tell

tell application "Nisus Writer Pro"
activate
tell application "System Events"
tell process "Nisus Writer Pro"
key code 45 using {command down} --create new document
key code 9 using {command down} --paste
end tell
end tell
end tell
Al Hatch
Bob Stern
Posts: 171
Joined: 2006-03-12 12:32:47

Re: Paste without Crash (AppleScript)

Post by Bob Stern »

Does it solve your problem if you run this AppleScript between copying the web page text and pasting it into NWP?

use scripting additions
set x to the clipboard as text
set the clipboard to x
hatchmo
Posts: 99
Joined: 2004-03-01 10:35:56
Location: Cotati, CA

Re: Paste without Crash (AppleScript)

Post by hatchmo »

Thanks. Yes, that prevents the crashing, and the text portion is pasted.
However, the advantage of my more elaborate script is that it preserves images.
Al Hatch
hatchmo
Posts: 99
Joined: 2004-03-01 10:35:56
Location: Cotati, CA

Re: Paste without Crash (AppleScript)

Post by hatchmo »

Good news! This month's version 3.4 update solves this problem.
Al Hatch
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Paste without Crash (AppleScript)

Post by martin »

hatchmo wrote: 2023-12-29 23:23:24 Good news! This month's version 3.4 update solves this problem.
Thanks for the update Al! The crashes were probably caused by a bug related to SVG images, which are not infrequently encountered on certain websites. That bug was fixed with Nisus Writer Pro version 3.4.
Vanceone
Posts: 211
Joined: 2013-05-03 07:06:31

Re: Paste without Crash (AppleScript)

Post by Vanceone »

Hmm... the release notes for Nisus 3.4 were pretty sparse. Did not mention any SVG changes. Was that part of the general Sonoma bug fix suite?
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Paste without Crash (AppleScript)

Post by martin »

Vanceone wrote: 2024-01-04 15:33:17 Hmm... the release notes for Nisus 3.4 were pretty sparse. Did not mention any SVG changes. Was that part of the general Sonoma bug fix suite?
There were a variety of unmentioned system compatibility/stability fixes in version 3.4, but the SVG fix should have been called out separately because it wasn't related to Sonoma. That bug affects some earlier systems as well.
Post Reply