Jump to content

Multi field inputbox


stev379
 Share

Recommended Posts

How can an inputbox be created such that it contains more than one field? Basically, I want to enter the admin password, a local user name and a new password for that local user. The script below works well, but there's a new window for each inputbox. I'd like to have all 3 fields in one box.

Dim $AdmPW, $UsrPW, $UsrNM

$AdmPW = InputBox("Admin Password", "Enter Administrator password.", "", "*")

$UsrNM = InputBox("User Name", "Enter user name.", "", "")

$UsrPW = InputBox("Set User Password", "Enter a password to set for local user " & $UsrNM, "", "*")

RunAsSet("Administrator", @Computername, $AdmPW)

Run("net user " & $UsrNM & $UsrPW)

Link to comment
Share on other sites

I'm trying to, but haven't used AutoIT for about a year, and didn't use it that much even then.

I'm just working through trying to get familiar with it but not having much success. Though I've tried many many things:), not able to get the gui to do what I want.

Link to comment
Share on other sites

; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>
GuiCreate("Example AutoIt Script", 392, 263,(@DesktopWidth-392)/2, (@DesktopHeight-263)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Label_1 = GuiCtrlCreateLabel("Admin Password: ", 10, 30, 110, 20, $SS_RIGHT)
$Label_2 = GuiCtrlCreateLabel("User's name: ", 10, 80, 110, 20, $SS_RIGHT)
$Label_3 = GuiCtrlCreateLabel("New user password: ", 10, 130, 110, 20, $SS_RIGHT)

$Input_AdmPW = GuiCtrlCreateInput("", 130, 30, 230, 20, $ES_PASSWORD)
    GuiCtrlSetState($Input_AdmPW, $GUI_FOCUS) ;start with cursor in this textbox
$Input_UsrNM = GuiCtrlCreateInput("", 130, 80, 230, 20)
$Input_UsrPW = GuiCtrlCreateInput("", 130, 130, 230, 20, $ES_PASSWORD)

$Button_OK = GuiCtrlCreateButton("OK", 30, 200, 120, 40)
    GuiCtrlSetState($Button_OK, $GUI_DEFBUTTON)
$Button_Cancel = GuiCtrlCreateButton("&Cancel", 240, 200, 120, 40)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_Cancel
        ExitLoop
    Case $msg = $Button_OK
        $AdmPW = GuiCtrlRead($Input_ADmPW)
        $UsrNM = GuiCtrlRead($Input_UsrNM)
        $UsrPW = GUICtrlRead($Input_UsrPW)
        Opt("RunErrorsFatal", 0);don't crash script
        RunAsSet("Administrator", @Computername, $AdmPW)
        $success = Run("net user " & $UsrNM & $UsrPW)
        If $success Then
            MsgBox(4096,"Done","Password reset for " & $UserNM)
            GuiCtrlSetData($Input_AdmPW, "")
            GuiCtrlSetState($Input_UsrNM, $GUI_FOCUS) ;start with cursor in this textbox
            GuiCtrlSetData($Input_UsrPW, "")
        Else
            MsgBox(4096,"Error", "Error resetting password...")
            GuiCtrlSetState($Input_UsrNM, $GUI_FOCUS) ;start with cursor in this textbox
        EndIf
        RunAsSet();reset AutoIt's Run credentials
    EndSelect
WEnd
Exit

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...