Jump to content
Sign in to follow this  
bremen

Extracting Data from my form / Clearing my form

Recommended Posts

bremen

So I have my form created (the one posted is left generic). Once The appropriate data is entered into the form how do I:

1) have AutoIT Retain that data for use in the script.

2) Begin using the script upon the clicking of Button 1

3) Earase all of the form data upon clicking button 2

#include <ButtonConstants.au3>

#include <ComboConstants.au3>

#include <DateTimeConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form2 = GUICreate("Form2", 594, 466, 194, 113)

$Input1 = GUICtrlCreateInput("Input1", 72, 8, 121, 21)

$User = GUICtrlCreateLabel("User", 16, 8, 50, 25)

$Password = GUICtrlCreateLabel("Password", 216, 8, 50, 17)

$Input2 = GUICtrlCreateInput("Input2", 272, 8, 121, 21)

$Aircraft = GUICtrlCreateCombo("combo box", 440, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))

$Input3 = GUICtrlCreateInput("Input3", 184, 88, 121, 21)

$Input4 = GUICtrlCreateInput("Input4", 184, 120, 121, 21)

$Input5 = GUICtrlCreateInput("Input5", 184, 152, 121, 21)

$Input6 = GUICtrlCreateInput("Input6", 184, 184, 121, 21)

$Input7 = GUICtrlCreateInput("Input7", 184, 216, 121, 21)

$Input8 = GUICtrlCreateInput("Input8", 184, 248, 121, 21)

$Input9 = GUICtrlCreateInput("Input9", 184, 280, 121, 21)

$Input10 = GUICtrlCreateInput("Input10", 184, 312, 121, 21)

$Input11 = GUICtrlCreateInput("Input11", 184, 344, 121, 21)

$Aircraf = GUICtrlCreateLabel("label", 8, 88, 58, 17)

$UOM = GUICtrlCreateLabel("UOM", 96, 48, 29, 17)

$Last = GUICtrlCreateLabel("Last", 192, 48, 104, 17)

$Las = GUICtrlCreateLabel("Last", 424, 48, 125, 17)

$Label1 = GUICtrlCreateLabel("Label1", 96, 80, 52, 25)

$Label2 = GUICtrlCreateLabel("Label2", 96, 120, 60, 17)

$Label3 = GUICtrlCreateLabel("Label3", 96, 152, 68, 17)

$Label4 = GUICtrlCreateLabel("Label4", 96, 184, 68, 17)

$Label5 = GUICtrlCreateLabel("Label5", 96, 216, 60, 17)

$Label6 = GUICtrlCreateLabel("Label6", 96, 248, 60, 17)

$Label7 = GUICtrlCreateLabel("Label7", 96, 280, 60, 17)

$Label8 = GUICtrlCreateLabel("Label8", 96, 312, 60, 17)

$Label9 = GUICtrlCreateLabel("Label9", 96, 344, 68, 17)

$Label10 = GUICtrlCreateLabel("Label10", 8, 184, 42, 17)

$Label11 = GUICtrlCreateLabel("Label11", 8, 248, 42, 17)

$Label12 = GUICtrlCreateLabel("Label12", 8, 304, 42, 17)

$Date1 = GUICtrlCreateDate("2013/05/06 10:34:13", 408, 88, 186, 21)

$Date2 = GUICtrlCreateDate("2013/05/06 10:36:39", 408, 120, 186, 21)

$Date3 = GUICtrlCreateDate("2013/05/06 10:36:53", 408, 152, 186, 21)

$Date4 = GUICtrlCreateDate("2013/05/06 10:36:56", 408, 184, 186, 21)

$Date5 = GUICtrlCreateDate("2013/05/06 10:36:58", 408, 216, 186, 21)

$Date6 = GUICtrlCreateDate("2013/05/06 10:37:17", 408, 248, 186, 21)

$Date7 = GUICtrlCreateDate("2013/05/06 10:37:27", 408, 280, 186, 21)

$Date8 = GUICtrlCreateDate("2013/05/06 10:37:31", 408, 312, 186, 21)

$Date9 = GUICtrlCreateDate("2013/05/06 10:37:40", 408, 344, 186, 21)

$Button1 = GUICtrlCreateButton("Button1", 192, 400, 75, 25)

$Button2 = GUICtrlCreateButton("Button2", 456, 408, 75, 25)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Share this post


Link to post
Share on other sites
BrewManNH

Answers:

1) Read the contents with GUICtrlRead and put it into a variable/array

2) No idea what you mean by begin using the script

3) Put this all into a function and call the function from within your script, process the information, return from the function and repeat.

BTW, unless you're going to be changing/interacting with the labels, you don't need to retain the control IDs with variables.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
bremen

I'm reading the help file regarding GUICtrlRead. I think i get how to read the information from lets say the combo box. What I'm having a hard time wrapping my head around is will AutoIT just retain the information that has been slected in the combo box.

In regards to question 2 I want the user to click button one and have the script start using the information in the form (that code hasnt been written yet.)

As far as your last two remarks I'm not following at all. I am a novice at best with Auto IT and even less so when it comes to GUI Forms

Share this post


Link to post
Share on other sites
BrewManNH

How long are you expecting it to be retained? If you read the contents of the control into a variable, as long as that variable exists it will hold what you put into it.

You need to understand the difference between Global and Local variables, see the help file for that, how to use functions in your scripts, how to use loops, probably arrays and simple variables as well. I'd suggest going through some of the tutorials in the Wiki section and start from there.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
bremen

Im only planing on retaining the data for the single instance of the script being run.

And thank you for giving me some direction on where to look. As I'm new to GUI I just dont know what to search for the answers I'm looknig for.

Share this post


Link to post
Share on other sites
Artisan

So I have my form created (the one posted is left generic). Once The appropriate data is entered into the form how do I:

1) have AutoIT Retain that data for use in the script.

2) Begin using the script upon the clicking of Button 1

3) Earase all of the form data upon clicking button 2

I think I understand what you're asking.

1) As far as retaining the data, the data is only present for as long as the GUI exists. It exists only in the same scope the GUI does. If you define a control to be Global, then its data is accessible through the whole script. If you declare it to be Local, then its data is only available in that function.  You can, of course, use additional variables to store the GUI data.  Example: $SomeGlobalVariable = GUICtrlRead($Aircraft)

2) Look up GUICtrlCreateButton in the help file. That will give you an excellent example of how to create and show a GUI with functional buttons.

Side Note: The example uses a Select block to call code based on what button was clicked. You can do that, but in practice it's usually better to use the Select block to call a function to do the work. It's just much easier to read/maintain/debug. If this doesn't make sense, don't worry about it for now. Just play with the different GuiCtrlCreate... functions.

3) Easy. You create your button, add it to the Select block I mentioned above, and have it call a function like EraseData() or whatever you want to call it. Then you make that function use GUICtrlSetData on each control to set its data to "" or 0 or some other dummy entry. Data erased.

Edited by Artisan

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  

×