displayDialog 方法 return 值用作字符串参数时导致错误 -1700
displayDialog method return value causes error -1700 when used as string argument
当我尝试打印 Var 'password'
时,它显示
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.
displayDialog
命令 returns 一个 AlertReply
记录,在 JXA 中看起来像这样:
{"buttonReturned":"OK", "textReturned":"password"}
要获取在对话框中输入的值,请尝试将 .textReturned
附加到 displayDialog
调用,如下所示:
var password = app.displayDialog('enter your password', {defaultAnswer: " "}).textReturned;
当我尝试打印 Var 'password'
时,它显示
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.
displayDialog
命令 returns 一个 AlertReply
记录,在 JXA 中看起来像这样:
{"buttonReturned":"OK", "textReturned":"password"}
要获取在对话框中输入的值,请尝试将 .textReturned
附加到 displayDialog
调用,如下所示:
var password = app.displayDialog('enter your password', {defaultAnswer: " "}).textReturned;