Paste without Crash (AppleScript)
Posted: 2023-07-07 00:00:10
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
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