When I try printing the Var 'password'
it says
Error -1700: Can't convert types.
var app = Application.currentApplication();
app.includeStandardAdditions = true;
var text = Application('System Events')
//prompt
var password = app.displayDialog('enter your password', {defaultAnswer: " "});
text.keystroke(password)
//returned message is Error -1700: Can't convert types.
The displayDialog
command returns an AlertReply
record, which looks like this in JXA:
{"buttonReturned":"OK", "textReturned":"password"}
To get the value entered in the dialog, try appending .textReturned
to the displayDialog
invocation, like this:
var password = app.displayDialog('enter your password', {defaultAnswer: " "}).textReturned;