当我尝试打印Var 'password'
时说
错误-1700:无法转换类型。
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.
答案 0 :(得分:1)
displayDialog
命令返回一条AlertReply
记录,在JXA中如下所示:
{"buttonReturned":"OK", "textReturned":"password"}
要获取在对话框中输入的值,请尝试将.textReturned
附加到displayDialog
调用中,如下所示:
var password = app.displayDialog('enter your password', {defaultAnswer: " "}).textReturned;