Pat*_*ook 5 passwords applescript inputbox
我想在 AppleScript 中创建一个与此完全相同的对话框输入框: 
除了没有锁左上角的图片。
另外,我需要能够保存两个输入。
我知道我可以使用,tell application "System Events" to display dialog "blah blah" default answer "" end tell但我找不到一种方法来拥有多个和标记的字段。
从 OSX 10.10 开始,AppleScript 本身不提供此功能。
\n\n要查看支持哪些 GUI 操作,请检查User Interaction标准添加的字典套件(可从viaStandardAdditions.def访问)。Script Editor.appFile > Open Dictionary... > StandardAdditions.osax
最接近的近似是单个输入字段对话框- 仅提示输入密码 - 如下(您已经在问题中注意到的限制,但只是为了说明如何提示输入密码以及如何使用自定义按钮):
\n\ndisplay dialog \xc2\xac\n "Installer is ..." default answer \xc2\xac\n "" buttons {"Cancel", "Install Software"} \xc2\xac\n default button 2 \xc2\xac\n with hidden answer\nRun Code Online (Sandbox Code Playgroud)\n\n为了得到你想要的,你需要一个第三方库,比如Pashua。
\n\n以下是如何在 Pashua 中定义请求的对话框并处理返回值:
\n\n# Define the dialog using a textual definition similar to a properties file.\nset dlgDef to "\n# Window title (if you don\'t set one explicitly (even if empty), it\'ll be \'Pashua\')\n*.title = \n\n# Add the hint (static text).\nst.type = text\nst.text = Installer is trying to install new software. Type your password to allow this.\n\n# Add the username field.\ntfn.type = textfield\ntfn.label = Name:\n\n# Add the password field.\ntfp.type = password\ntfp.label = Password:\n\n# Add the buttons.\ncb.type = cancelbutton\ndb.type = defaultbutton\ndb.label = Install Software\n"\n\n# Show the dialog. \n# Return value is a record whose keys are the element names from the dialog\n# definition (e.g., "tfn" for the usernam text field) and whose\n# values are the values entered (for input fields) or \n# whether a given button was clicked or not ("1" or "0")\nset theResult to showDialog(dlgDef, "")\n\n# Process the returned values.\nif cb of theResult is "1" then\n display alert "User canceled the dialog."\nelse\n display alert "name=[" & tfn of theResult & "]; password=[" & tfp of theResult & "]"\nend if\nRun Code Online (Sandbox Code Playgroud)\n\n该对话框将如下所示:
\n\n
设置 Pahua 的概述
\n\n注意:这是一个简化的概述;有关完整说明,请参阅下载的光盘映像中的Read me.html和。Documentation.html
Pashua.app、或 - 必要时 - 放在与调用脚本相同的文件夹中。\n\ /Applicationsn~/ApplicationsPashua.app是呈现对话框的应用程序(当对话框打开时,菜单栏显示Pashua)。showDialog和getPashuaPath)Examples/AppleScript/Pashua.scpt复制到脚本中。\n\ngetPashuaPath:将行替换return (path to applications folder from system domain as text) & "Pashua.app"为return (path to applications folder from system domain as text) & "Pashua.app:"。| 归档时间: |
|
| 查看次数: |
6703 次 |
| 最近记录: |