#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>


$Auauto = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","Autoadminlogon")
$Auuser = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","Defaultusername")
$Aupass = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","Defaultpassword")

Func _Autologin()
If $Auauto = 1 Then
	$Autologin = GUICreate("当前是自动登录状态", 267, 122, -1, -1, -1, -1,$window)
Else
	$Autologin = GUICreate("当前不是自动登录状态", 267, 122, -1, -1, -1, -1,$window)
EndIf	
GUISetBkColor(0xEFF0F2)
$AuButton1 = GUICtrlCreateButton("设置", 120, 80, 59, 25)
$AuButton2 = GUICtrlCreateButton("取消登录", 184, 80, 59, 25)
$AuButton3 = GUICtrlCreateButton("用户账户", 16, 80, 91, 25)
$AuLabel1 = GUICtrlCreateLabel("用户名：", 16, 16, 52, 17)
$AuLabel2 = GUICtrlCreateLabel("密  码：", 16, 48, 54, 17)
$AuInput1 = GUICtrlCreateInput($Auuser, 80, 12, 161, 21)
$AuInput2 = GUICtrlCreateInput($Aupass, 80, 44, 161, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
GUISetState(@SW_SHOW)


While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			GUIDelete($Autologin)
			ExitLoop
		Case $AuButton1
			RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","Defaultusername","REG_SZ",GUICtrlRead($AuInput1))
			RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","Defaultpassword","REG_SZ",GUICtrlRead($AuInput2))
			RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","Autoadminlogon","REG_SZ",1)
			WinSetTitle($Autologin,"","您当前是自动登录状态")
			MsgBox(64,"提示","修改完成！")
		Case $AuButton2
			RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","Autoadminlogon","REG_SZ",0)
			WinSetTitle($Autologin,"","您当前不是自动登录状态")
			MsgBox(64,"提示","修改完成！")
		Case $AuButton3
			Run("control userpasswords2")
			
	EndSwitch
WEnd

EndFunc
