Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X Javascript for Automation displayDialog

I'm trying to get a simple dialog to show for a workflow I'm working on, but using JXA I keep getting the error: Expecting object specifier, argument has no object specifier. I don't know what to pass in for the object Specifier. My code is below, it takes issue at line 11 where I call the dialog

function run() {

    app = Application.currentApplication();
    app.includeStandardAdditions = true;
    //Error Here
    var who = app.displayDialog('Whose server is this?', {
        withTitle: 'Whose Server...'
    })

    return who
}
like image 708
richbai90 Avatar asked Jun 20 '26 13:06

richbai90


1 Answers

Read this unofficial cookbook about User-Interactions, it helps me about these alert things.

In details:

function prompt(text, defaultAnswer) {
  var options = { defaultAnswer: defaultAnswer || '' }
  try {
    return app.displayDialog(text, options).textReturned
  } catch (e) {
    return null
  }
}
like image 147
Puttin Avatar answered Jun 23 '26 01:06

Puttin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!