Page 1 of 1

Accessing Applescript Script Libraries?

Posted: 2017-03-27 13:58:08
by Vanceone
Is there a way to access Applescript Script Libraries from Nisus? I have a Script Library that installed in ~/Library/Script Libraries/ and an applescript file that uses it.

One neat thing about Nisus is that it runs Applescript sctp files directly. But while my script runs fine outside of Nisus, inside of nisus it's not working; and I can only assume it's because Nisus running applescript does not open script libraries?

I hope that's not true, I really do. I'd love to have a large applescript library to use with short and sweet Applescript commands in Nisus code. Particularly since Yosemite you can use applescript-objC code from Applescript running in Nisus.

Re: Accessing Applescript Script Libraries?

Posted: 2017-03-27 15:45:44
by Vanceone
Also, how can you pass information to your applescript? Like, say, an array or dictionary?

Re: Accessing Applescript Script Libraries?

Posted: 2017-03-27 19:39:13
by phspaelti
There are no simple answers here, especially since sandboxing has interrupted a lot of the back and forth that used to be possible between Nisus and AppleScript. In particular Nisus cannot use AppleScript to access other applications.

If your AppleScript is self-contained you can just make it a service, and then it will be available in the Service menu. For more on this see the previous discussion https://www.nisus.com/forum/viewtopic.php?f=17&t=5948

Passing values to AppleScript from Nisus is usually done by constructing a string of the form "set myValue to x" and then running it as an AppleScript.
Another method is to pass values via the clipboard.

If you wanted to pass an array to AppleScript, you could probably use the ".join" command in Nisus, pass it as a single value, and then split it in AppleScript. I've never tried this though.

Going the other way, from AppleScript to Nisus, you usually make heavy use of the "Do Menu Macro with macro" command in AppleScript. My general preference is to write as much of the macro as possible in Nisus, but it really depends on the problem.

Re: Accessing Applescript Script Libraries?

Posted: 2017-03-28 05:19:53
by Vanceone
Thanks phspaelti. I kind of thought that was the case. Transferring information back and forth between Applescript and Nisus seems harder than it should be. Also, the "Send Selector" command is very limited, correct? We cannot send any arguments with our selector or use multiple argument selectors?

Among other things, I'm contemplating building a series of custom dialogs. Nisus's macro language cannot do that, so I have to resort to Applescript (and ApplescriptObjC) and pass values back and forth.

Is each call to "Run Applescript" self contained, or does each call stand alone, and I'd have to repeat all setup code?

Re: Accessing Applescript Script Libraries?

Posted: 2017-05-11 16:22:11
by martin
Vanceone wrote:Also, the "Send Selector" command is very limited, correct? We cannot send any arguments with our selector or use multiple argument selectors?
That's correct, the "Send Selector" command in the Nisus Macro Language cannot pass arguments, or use multiple argument selectors. It was really only intended to allow macros to trigger AppKit action methods like -deleteToEndOfLine:
Is each call to "Run Applescript" self contained, or does each call stand alone, and I'd have to repeat all setup code?
Each call to "Run Applescript" is compiled and run independently via separate NSAppleScript instances, so you'll have to repeat any setup/teardown code.

Re: Accessing Applescript Script Libraries?

Posted: 2017-09-07 17:12:06
by Bob Stern
This module loader OSAX might be able to circumvent sandboxing:

http://www.script-factory.net/software/ ... index.html