Sign in to follow this  
Followers 0
terraya

Read Input and Save [with some options]

2 posts in this topic

Hello everyone,

 

i am working atm at a small programm,

i want to make it work like this:

I click on "NEW" i can add a new Customer,

i want to read the input and save it (the thing is i want to make it

work for me and my friend in the internet so i think we need a internet database but firstly

i want to make it work on my laptop only for me)

 

i dont know in what to save it cuz "txt" is a bit weird , why?

becouse later i want to make a button which search for the "customer"

 

if i press on the other button not "NEW", if i press on "Search", then i have to

write the customers name in, and the info i got from the customer has to show  up

and be changeable.

 

i hope someone understand my poor english xD ,

well here is the script which is not finisht cuz i dont know how to finish the idea.

 

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$GUI = GUICreate("Form1", 429, 148, 249, 151)
$NEW = GUICtrlCreateButton("NEW", 48, 24, 75, 25)
$Search = GUICtrlCreateButton("Search", 48, 54, 75, 25)
$SAVE = GUICtrlCreateButton("SAVE", 328, 112, 75, 25)
$EDIT = GUICtrlCreateButton("EDIT", 328, 112, 75, 25)
GUISetState(@SW_SHOW, $GUI)
GUICtrlSetState ($SAVE, $GUI_HIDE)
GUICtrlSetState ($EDIT, $GUI_HIDE)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $NEW
            GUICtrlSetState ($SAVE, $GUI_SHOW)
            _NewCustomer()
         Case $Search
            GUICtrlSetState ($EDIT, $GUI_SHOW)
            _SearchCustomer()
         Case $SAVE
            ;not completed yet cuz i dont know in which format to save it to
            ;read it again in the GUI to make it edit able.


    EndSwitch
WEnd

Func _SearchCustomer()

   $Input2 = GUICtrlCreateInput("", 136, 57, 121, 21)

EndFunc

Func _NewCustomer()

   $Input1 = GUICtrlCreateInput("", 136, 27, 121, 21)

EndFunc

 

test functions.au3

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You are no reason to create a control every time like in _SearchCustomer and _NewCustomer funcs. I writte an very noob example saving the data in Ini files in your computer.

When you save you need first read the value in input control, you can do it using GuiCtrlRead($Input1). $Input1 are nothing more than a variable that stores the control ID to use in functions like GuiCtrlRead, GuiCtrlSetState, GuiCtrlSetColor, etc

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 405, 438, 192, 124)
$Label1 = GUICtrlCreateLabel("Name:", 8, 8, 35, 17)
$InputName = GUICtrlCreateInput("", 72, 8, 185, 21)
$Label = GUICtrlCreateLabel("Credit Card:", 8, 40, 59, 17)
$InputCreditCard = GUICtrlCreateInput("", 71, 34, 185, 21)
$Label3 = GUICtrlCreateLabel("Age:", 40, 72, 26, 17)
$InputAge = GUICtrlCreateInput("", 72, 72, 185, 21)
$ButtonSave = GUICtrlCreateButton("Save", 88, 112, 169, 33)
$List1 = GUICtrlCreateList("", 8, 192, 153, 227)
$Label4 = GUICtrlCreateLabel("Name:", 168, 200, 35, 17)
$LabelName = GUICtrlCreateLabel("", 208, 200, 188, 20)
$Label6 = GUICtrlCreateLabel("Credit Card:", 168, 232, 59, 17)
$LabelCreditCard = GUICtrlCreateLabel("", 232, 232, 164, 20)
$Label8 = GUICtrlCreateLabel("Age:", 168, 264, 59, 17)
$LabelAge = GUICtrlCreateLabel("", 232, 264, 164, 20)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$aSecNames = IniReadSectionNames("Customer.ini")

For $i = 2 to UBound($aSecNames)

    GUICtrlSetData($List1,$aSecNames[$i-1])

Next

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ButtonSave
            $Name = GUICtrlRead($InputName)
            $CreditCard = GUICtrlRead($InputCreditCard)
            $Age = GUICtrlRead($InputAge)

            IniWrite("Customer.ini",$Name,"CreditCard",$CreditCard)
            IniWrite("Customer.ini",$Name,"Age",$Age)

            $aSecNames = IniReadSectionNames("Customer.ini")

            For $i = 2 to UBound($aSecNames)

                GUICtrlSetData($List1,$aSecNames[$i-1])

            Next
        Case $List1
            $Name = GUICtrlRead($List1)
            $CreditCard = IniRead("Customer.ini",$Name,"CreditCard","None")
            $Age = IniRead("Customer.ini",$Name,"Age","None")

            GUICtrlSetData($LabelName,$Name)
            GUICtrlSetData($LabelCreditCard,$CreditCard)
            GUICtrlSetData($LabelAge,$Age)

    EndSwitch
WEnd

 

Edited by GordonFreeman

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

  • Similar Content

    • nlta1992
      By nlta1992
      I want creat GUI, have button 1 to 10, but only use loop for ... to ... step ... next.
      Thanks.
    • Gorby7
      By Gorby7
      I have an Autoit-based client GUI that uses a single MS SQL Server database. I have no problem connecting to and executing queries against this database from my AutoIT code, with the below exception:
      One of the database's stored procedures I need to execute requires a parameter that is a table. I've set up the appropriate table_type on the database and everything works fine on the database itself when I execute the stored proc with a table variable for the parameter (no AutoIT involved). The problem is that I can't figure out how to pass a table parameter from AutoIT, assuming it's even possible. The code below shows the two methods I've tried, both methods return a RecordSet object that is at EOF.
      #include <Array.au3> Opt("MustDeclareVars", 0) $sDBSrv = "ITSQL01.domain.com" $sDBName = "INVDEV" $sADOName = "ADODB.Connection" $oSQLConn = ObjCreate($sADOName) $sConnStr = "Driver={SQL Server};Server=" & $sDBSrv & ";Database=" & $sDBName & ";Trusted_Connection=yes;" $oSQLConn.Open ($sConnStr) $rsoFacFriendly = $oSQLConn.Execute("SELECT TOP 5 FriendlyName FROM Facility") If Not $rsoFacFriendly.EOF Then $aFacFriendly = $rsoFacFriendly.GetRows() _ArrayDisplay($aFacFriendly) $rsoSPResults = $oSQLConn.Execute("EXEC spTableParameterPassTest " & $aFacFriendly) Select Case $rsoSPResults.EOF = False MsgBox(0, "sp exec1", "not end of file") $aSPResults = $rsoSPResults.GetRows() _ArrayDisplay($aSPResults) Case IsObj($rsoSPResults) = 0 MsgBox(0, "sp exec1", "rso isn't even an object") Case $rsoSPResults.EOF = True MsgBox(0, "sp exec1", "At end of file") Case Else MsgBox(0, "sp exec1", "Something else happened") EndSelect $rsoSPResults = 0 $rsoSPResults = $oSQLConn.Execute("EXEC spTableParameterPassTest " & $rsoFacFriendly) Select Case $rsoSPResults.EOF = False MsgBox(0, "sp exec2", "not end of file") $aSPResults = $rsoSPResults.GetRows() _ArrayDisplay($aSPResults) Case IsObj($rsoSPResults) = 0 MsgBox(0, "sp exec2", "rso isn't even an object") Case $rsoSPResults.EOF = True MsgBox(0, "sp exec2", "At end of file") Case Else MsgBox(0, "sp exec2", "Something else happened") EndSelect $rsoSPResults = 0 $rsoFacFriendly = 0 $oSQLConn.Close $oSQLConn = 0 Exit  
    • Swatcat
      By Swatcat
      Hi All,
      So I need Help.
      I am developing code to handle Authentication Popup For IE. The issue I am facing is that this code runs smoothly on unlock desktop but fails on VM machine and when machine is locked. So could you suggest what should I do to make it work. My automation Tool is a Selenium Based tool and is able to launch the script, but the AutoIT Script is unable to pass the username and password on the authentication popup.
      Below is the code.
      I am passing the values through Command line arguments.
      #include <Array.au3> Local $browser, $BAuthMode, $BWinAuthUserName, $BWinAuthPassword, $BChromeClaimsURL, $BChromePolicyURL, $BIEPolicyURL, $BIEClaimsURL; $browser = $CMDLine[1] $BAuthMode = $CMDLine[2] $BWinAuthUserName = $CMDLine[3] $BWinAuthPassword = $CMDLine[4] $BChromeClaimsURL = "" $BChromePolicyURL = "" $BIEURL = "" ;$BIEClaimsURL = "" If $browser = "chrome" And $BAuthMode = "m" Then If WinExists($BChromeClaimsURL,"") Then WinWaitActive($BChromeClaimsURL) ; set control to the window for proxy authentication Sleep(500) Send("{ESCAPE}") ElseIf WinExists($BChromePolicyURL,"") Then WinWaitActive($BChromePolicyURL) ; set control to the window for proxy authentication Sleep(500) Send("{ESCAPE}") EndIf ElseIf $browser = "ie" And $BAuthMode = "m" Then If WinExists($BIEPolicyURL,"") Then WinExists($BIEPolicyURL) ; set control to the window for proxy authentication Sleep(500) Send("{ESCAPE}") ElseIf WinExists($BIEClaimsURL,"") Then WinWaitActive($BIEClaimsURL) ; set control to the window for proxy authentication Sleep(500) Send("{ESCAPE}") EndIf ElseIf $browser = "ie" And $BAuthMode = "w" Then WinWaitActive($BIEURL,"","20") if(WinExists($BIEURL)) Then Sleep(500) Send($BWinAuthUserName & "{TAB}") ; send username and press TAB Sleep(100) Send($BWinAuthPassword & "{ENTER}") ; send the password and press enter Sleep(100) EndIf ElseIf $browser = "chrome" And $BAuthMode = "w" Then If WinExists($BChromeClaimsURL,"") Then WinWaitActive($BChromeClaimsURL) ; set control to the window for proxy authentication Sleep(500) Send($BWinAuthUserName & "{TAB}") ; send username and press TAB Send($BWinAuthPassword & "{ENTER}") ; send the password and press enter ElseIf WinExists($BChromePolicyURL,"") Then WinWaitActive($BChromePolicyURL) ; set control to the window for proxy authentication Sleep(500) Send($BWinAuthUserName & "{TAB}") ; send username and press TAB Send($BWinAuthPassword & "{ENTER}") ; send the password and press enter EndIf EndIf WinSetState("[ACTIVE]", "", @SW_RESTORE) Sleep(500) WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)  
       
       
       
    • Gowrisankar
      By Gowrisankar
      Dear members of the forum,
      I'm new to AutoIt and I'm having a good time exploring and enjoying the features of AutoIt.
      For one of my tasks, I've to open few particular mails from outlook based on subject of the mails and then print the mails. Can someone please guide me how to do it?
      My question could be very silly for experts. But I'm just a beginner. Kindly advice.
      Thanks and regards,
      Gowrisankar R.
    • ur
      By ur
      We are trying to automate the installation testing before sending to end users, our product.
      For Silent Installation, we have completed this part.
      But for GUI, the default installation is completed by sending the keys based on the window.
      But for GUI custom installation, we are struck.
      How to enable or disable features in the below screen using GUI automation.?