Jump to content

Using a GUI to gather Data


Recommended Posts

Hello,

Bit new to all this so go easy please!!

Ive created a simple GUI that asks for the person running the script to enter three values. A generic username and password as well as a unique identifier.

What I now want to do is get the GUI to retain that data for use later in the script (to log in to various applications) after the continue button is pressed.

My script should be shown below can anyone help??

Thanks,

Matt.

#include <GUIConstants.au3>

; GUI
GuiCreate("Please enter the details requested:", 400, 400)

GUICtrlCreateLabel("Please enter a username and password which has",70,60) 
GUICtrlCreateLabel("full access to the FMS module. When entering the",70,75)
GUICtrlCreateLabel("DFES number of the school please include the 908",70,90)
GUICtrlCreateLabel("prefix or the number will not be validated.",70,105)

GUICtrlCreateLabel("FMS Username:", 20, 200, 130, 20)
GUICtrlCreateLabel("FMS Password:", 20, 230, 130, 20)
GUICtrlCreateLabel("School DFES Number:", 20, 260, 130, 20)

$USER = GuiCtrlCreateInput("", 200, 193, 130, 20)
$PASS = GuiCtrlCreateInput("", 200, 223, 130, 20)
$DFES = GuiCtrlCreateInput("", 200, 253, 130, 20)

GuiCtrlCreateButton("Continue", 10, 330, 100, 30)

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd
Link to comment
Share on other sites

  • Moderators

Look at "Variable" and "GUICtrlRead" in the help file.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Try this. Have not tested it so typos might occur..:P

#include <GUIConstants.au3>
Local $user, $pwd, $id
If guiUserID($user, $pwd, $id)
   ;Continue
   MsgBox(48, "User ok", "Hello " & $user)
Else
   MsgBox(16, "User canceled", "Hello " & $user)
EndIf
Func guiUserID(ByRef $user, ByRef $pwd, ByRef $id)
   ; GUI
   Local $gui = GuiCreate("Please enter the details requested:", 400, 400)

   GUICtrlCreateLabel("Please enter a username and password which has",70,60) 
   GUICtrlCreateLabel("full access to the FMS module. When entering the",70,75)
   GUICtrlCreateLabel("DFES number of the school please include the 908",70,90)
   GUICtrlCreateLabel("prefix or the number will not be validated.",70,105)

   GUICtrlCreateLabel("FMS Username:", 20, 200, 130, 20)
   GUICtrlCreateLabel("FMS Password:", 20, 230, 130, 20)
   GUICtrlCreateLabel("School DFES Number:", 20, 260, 130, 20)

   Local $USERCTL = GuiCtrlCreateInput("", 200, 193, 130, 20)
   Local $PASSCTL = GuiCtrlCreateInput("", 200, 223, 130, 20)
   Local $DFESCTL = GuiCtrlCreateInput("", 200, 253, 130, 20)
   ;Excped you to create cancel button?
   Local $cancel = 1 ;
   Local $CONTINUECTL = GuiCtrlCreateButton("Continue", 10, 330, 100, 30)
   Local $CANCELCTL = GuiCtrlCreateButton("Cancel", 10 + 100 + 5, 330, 100, 30)
   GuiSetState()
   Local $msg
   Do 
      $msg = GuiGetMsg()
      Switch $msg
         Case $CANCELCTL
            ExitLoop
         Case $CONTINUECTL
            $cancel = 0
            ExitLoop
      EndSwitch 
   Until $msg = $GUI_EVENT_CLOSE
   IF $cancel = 0 Then 
      $user = GuiCtrlRead($USERCTL)
      $pwd = GuiCtrlRead($PASSCTL)
      $id = GuiCtrlRead($DFESCTL)
   Endif
   GUIDelete($gui)
   ; Note assosiatig the variable name correctly with a true or false
   Return Not $cancel
EndFunc
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...