Creates and displays a configurable dialog box that accepts credentials information from a user.
#Include <WinAPIEx.au3>
_WinAPI_ShellUserAuthenticationDlg ( $sCaption, $sMessage, $sUser, $sPassword, $sTarget [, $iFlags [, $iError [, $fSave [, $hBitmap [, $hParent]]]]] )
$sCaption | The title for the dialog box. |
$sMessage | A brief message to display in the dialog box. |
$sUser | The user name to populate the credential fields in the dialog box. For domain users, the string must be in the following format (if domain is not specified, the trget string is used as the domain): DomainName\UserName |
$sPassword | The initial password. |
$sTarget | The name of the target, typically a server name. This parameter is used to identify target information when storing and retrieving credentials. |
$iFlags | [可选参数] The flags that specifies behavior for this function. It can be a bitwise-OR combination of zero or more of the following values. $CREDUI_FLAGS_ALWAYS_SHOW_UI $CREDUI_FLAGS_COMPLETE_USERNAME $CREDUI_FLAGS_DO_NOT_PERSIST $CREDUI_FLAGS_EXCLUDE_CERTIFICATES $CREDUI_FLAGS_EXPECT_CONFIRMATION $CREDUI_FLAGS_GENERIC_CREDENTIALS $CREDUI_FLAGS_INCORRECT_PASSWORD $CREDUI_FLAGS_KEEP_USERNAME $CREDUI_FLAGS_PASSWORD_ONLY_OK $CREDUI_FLAGS_PERSIST $CREDUI_FLAGS_REQUEST_ADMINISTRATOR $CREDUI_FLAGS_REQUIRE_CERTIFICATE $CREDUI_FLAGS_REQUIRE_SMARTCARD $CREDUI_FLAGS_SERVER_CREDENTIAL $CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX $CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS $CREDUI_FLAGS_VALIDATE_USERNAME |
$iError | [可选参数] The system error code that specifies why the credential dialog box is needed. |
$fSave | [可选参数] Specifies whether the "Save" check box is selected in the dialog box (it makes sense only if the $CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX flag is used), valid values: TRUE - Selected. FALSE - Deselected. (Default) |
$hBitmap | [可选参数] A bitmap handle to display in the dialog box. If this parameter is 0, the default bitmap is used. The bitmap size is limited to 320x60 pixels. |
$hParent | [可选参数] The dialog box is modal with respect to the parent window. If this parameter is 0, the desktop is the parent window of the dialog box. |
Success | The array containing the following information: |
[0] | The user name, including domain name (if necessary). |
[1] | The password. |
[2] | The state of the "Save" check box. |
失败: | 返回 0 并设置 @error 标志为非 0 值. If the function is canceled by the user, @extended flag will |
在MSDN中搜索
#Include <APIConstants.au3>
#Include <String.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Authentication.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Global $Data[3] = ['', '', 0]
While 1
$Data = _WinAPI_ShellUserAuthenticationDlg('Authentication', 'To continue, type a login and password, and then click OK.', $Data[0], $Data[1], 'MyScript', BitOR($CREDUI_FLAGS_ALWAYS_SHOW_UI, $CREDUI_FLAGS_EXPECT_CONFIRMATION, $CREDUI_FLAGS_GENERIC_CREDENTIALS, $CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX), 0, $Data[2], $hBitmap)
If @error Then
Exit
EndIf
If (StringCompare($Data[0], 'AutoIt')) Or (StringCompare($Data[1], _StringEncrypt(0, 'DC7E430A1C88', '123'))) Then
If $Data[2] Then
_WinAPI_ConfirmCredentials('MyScript', 0)
EndIf
MsgBox(16, 'Error', 'You have typed an incorrect login or password, it should be "AutoIt" and "123".')
Else
If $Data[2] Then
_WinAPI_ConfirmCredentials('MyScript', 1)
EndIf
ExitLoop
EndIf
WEnd