The following commands allow macros to interact with standard UI controls. They are generally NOT recommended since UIs don’t represent a stable API, but could let a macro achieve something that is otherwise not possible.
Press Default Button v1.1
This command will dismiss the currently displayed dialog as if the user had pressed the default button (the one that glows blue), eg:
Menu 'Add Bookmark As'
Press Default Button
Important: some displayed dialogs are modal, meaning that they prevent further macro execution until the dialog is dismissed. To dismiss a modal dialog the Delayed Press Default Button command will need to be used instead.
Delayed Press Default Button v1.1
If this command directly precedes a command that may display a dialog to the user, it will cause the dialog to be dismissed as if the user had pressed the default button. An example:
Delayed Press Default Button
Save
Press Button caption v1.2
Works just as the Press Default Button command (above), but instead of pressing the default button will press the button that displays the given caption text. If a button with the given caption does not exist then an error will be displayed.
Warning: button captions change depending on the active localization. A command to press a particular button may fail for another localization where the caption is different.
Delayed Press Button caption v1.2
Works just as the Delayed Press Default Button command (above), but instead of pressing the default button will press the button that displays the given caption text. If a button with the given caption does not exist then an error will be displayed.
Warning: button captions change depending on the active localization. A command to press a particular button may fail for another localization where the caption is different.
Send Selector selectorName v1.3
Selectors are a concept found in Cocoa, a framework provided by Apple to help developers write applications for macOS. Nisus Writer in a large part make use of Cocoa and thus selectors.
An individual selector is essentially an identifier (like a macro command name) used to by Cocoa to perform some action. One example is the action of extending the selection forward by a word, whose selector is 'moveWordForwardAndModifySelection:'. To send this selector using the macro language:
$isSent = Send Selector 'moveWordForwardAndModifySelection:'
The Send Selector command returns @true if the selector is known and was acted upon by Nisus Writer, otherwise @false. Selectors are generally acted upon by the interface element that has focus, eg: the active text area, but can be picked up by other parts of the application.
A list of some useful selectors can be found on this page listing default key bindings, though there are others.
Send Text text v1.3
This command sends the given piece of text to the interface element that has focus, generally inserting it. Returns true if the text could be sent, otherwise @false.
Note: normally a macro should interact with the document area using the Insert Text or Type Text commands. Send Text is only provided as a way to interact with ancillary text areas inaccessible to proper macro commands, eg: a text field in a dialog/prompt.
Previous Chapter AppleScript |
<< index >> |
Next Chapter Other Commands |