Sign in to follow this  
Followers 0
SuperFletch

Using a GUI to gather Data

6 posts in this topic

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

Share this post


Link to post
Share on other sites



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


[center]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.[/center]

Share this post


Link to post
Share on other sites

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

Thanks, I'd looked at various bits of the help but couldn't make enough sense of them to work out which ones I needed.

Knowing that these are the functions I need will definately help.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I did a simular thing like this with an INI file. Create the ini with the value's entered by the user. (GuiCtrlRead and IniWrite)

Later in another script using the same value's with IniRead to a $Var

Share this post


Link to post
Share on other sites

Thanks folks.

I've got it done now, and put in an exit button too!! (Always planned to honest)!

After a lot of tinkering it even works - well chuffed. :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0