Jump to content

Multi Form Help


Cwelle
 Share

Recommended Posts

I am building a data capture app that has several purposes:

1. EULA Acceptance

2. Data collection from text entry form then saved to a text file

3. Execute application

4. Watch application process time and capture time the application ends then save to the previous line in the text file.

I am very new to AutoIT and programming in general. I have been able to create the EULA and the text entry form in Koda. I've been looking for different scripts already written that could help me figure out most of this but am having problems in finding it.

I am stuck on getting from the 1st form (EULA) to the 2nd Form (Datacollection) then to save the entered data to a text file, and last the watch process timer function.

Any help or suggestions would be greatly appreciated.

Thanks,

CW

Link to comment
Share on other sites

  • Moderators

Cwelle,

Welcome to the AutoIt forum. :)

Please post the code you have so far - it always helps in understanding what is going on and it saves us having to write something from scratch. :)

When you post code please use Code tags - put [autoit] before and [/autoit] after the code.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thank you. Here is the EULA Form I created.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### 
$Form1 = GUICreate("APP", 484, 618, -1, -1, BitOR($WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU), 0)
GUISetBkColor(0xFFFBF0)
$Edit1 = GUICtrlCreateEdit("", 24, 40, 443, 498, BitOR($ES_OEMCONVERT,$ES_READONLY,$WS_VSCROLL,$WS_BORDER), 0)
$eula = ("This EULA." & @CRLF & @CRLF & _
"1. License Grant. We grant to You, a royalty-free, non-transferable and non-exclusive license..... " & @CRLF & _
"2. Software Format.  You may only use the Software as provided in object code and the related documentation....." & @CRLF & _
"3. Term. You will use the Software for no longer than the Evaluation Period.  This Agreement ...")
GUICtrlSetData(-1, $eula)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$Button2 = GUICtrlCreateButton("Decline", 240, 544, 89, 25)
$Button1 = GUICtrlCreateButton("Accept", 360, 544, 89, 25)
$License = GUICtrlCreateLabel("License Agreement", 32, 16, 120, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Form1
        Case $License
        Case $Button2
            Exit
        Case $Button1
    EndSwitch
WEnd

Here is the Data collection form

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### 
$Form2 = GUICreate("Data Collection", 371, 186, 306, 149)
$Name = GUICtrlCreateInput("", 72, 16, 281, 21)
$Label1 = GUICtrlCreateLabel("Name:", 16, 16, 35, 17)
$Demo = GUICtrlCreateCheckbox("Demo?", 16, 72, 97, 17)
$Company = GUICtrlCreateInput("", 72, 48, 281, 21)
$Label2 = GUICtrlCreateLabel("Company", 16, 48, 48, 17)
$Purpose = GUICtrlCreateInput("", 72, 104, 281, 21)
$Label3 = GUICtrlCreateLabel("Purpose", 16, 104, 43, 17)
$Cancel = GUICtrlCreateButton("Cancel", 160, 136, 89, 33)
$Start = GUICtrlCreateButton("Start", 264, 136, 89, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Cancel
            Exit


    EndSwitch
WEnd
Link to comment
Share on other sites

  • Moderators

Cwelle,

As you are only using 1 GUI at a time, the easiest way to proceed is to delete the current one and then create the new one - like this: :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ###
$Form1 = GUICreate("APP", 484, 618, -1, -1, BitOR($WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU), 0)
GUISetBkColor(0xFFFBF0)

$Edit1 = GUICtrlCreateEdit("", 24, 40, 443, 498, BitOR($ES_OEMCONVERT,$ES_READONLY,$WS_VSCROLL,$WS_BORDER), 0)
$eula = ("This EULA." & @CRLF & @CRLF & _
"1. License Grant. We grant to You, a royalty-free, non-transferable and non-exclusive license..... " & @CRLF & _
"2. Software Format.  You may only use the Software as provided in object code and the related documentation....." & @CRLF & _
"3. Term. You will use the Software for no longer than the Evaluation Period.  This Agreement ...")
GUICtrlSetData(-1, $eula)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)

$Button2 = GUICtrlCreateButton("Decline", 240, 544, 89, 25)
$Button1 = GUICtrlCreateButton("Accept", 360, 544, 89, 25)
$License = GUICtrlCreateLabel("License Agreement", 32, 16, 120, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)

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

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Button2
            Exit
        Case $Button1
            GUIDelete($Form1)
            ExitLoop
    EndSwitch
WEnd

#Region ### START Koda GUI section ###
$Form2 = GUICreate("Data Collection", 371, 186, 306, 149)

$Name = GUICtrlCreateInput("", 72, 16, 281, 21)
$Label1 = GUICtrlCreateLabel("Name:", 16, 16, 35, 17)
$Demo = GUICtrlCreateCheckbox("Demo?", 16, 72, 97, 17)
$Company = GUICtrlCreateInput("", 72, 48, 281, 21)
$Label2 = GUICtrlCreateLabel("Company", 16, 48, 48, 17)
$Purpose = GUICtrlCreateInput("", 72, 104, 281, 21)
$Label3 = GUICtrlCreateLabel("Purpose", 16, 104, 43, 17)
$Cancel = GUICtrlCreateButton("Cancel", 160, 136, 89, 33)
$Start = GUICtrlCreateButton("Start", 264, 136, 89, 33)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Cancel
            Exit
        Case $Start
            
    EndSwitch
WEnd

Please ask if you have any questions. :)

Should you in the future need more than one GUI on screen at a time, I recommend a look at the Managing Multiple GUIs tutorial in the Wiki. :P

Next bit "saved to a text file" - do you have an existing file or do we have to create it? Either way we will need to use GUICtrlRead to get the contents of the inputs and then FileWrite or FileWriteLine to get them into the file.

Have a go at it yourself and see how you get on - you know where we are if you run into difficulties. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thank you for that.

If the file is not already created it needs to create it. If already created, it needs to add to the file on a new line.

($Date, $Name, $Company, $Purpose, $Demo, $Starttime, $Endtime) similar reporting in this format or similar.

Link to comment
Share on other sites

As for code in watching the process run I have found this code that I was going to try.

$ProcessName = "Notepad.exe"

If ProcessExists($ProcessName) Then
    MsgBox(0,"Running",$ProcessName & " is running.")
Else
    MsgBox(0,"Not Running",$ProcessName & " is not running.")
EndIf

Create a loop with a sleep to run the loop again if the process is running. Once the process ends it writes the time to the end of the line and exits the application.

Link to comment
Share on other sites

  • Moderators

Cwelle,

ProcessExists is definitely the way to go here - look at TimerInit and TimerDiff to get the elapsed time. :)

You seem to have it well under control - I look forward to the next version of the script. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

This was great help Thank you very much.

I was wondering though with the same code above is it possible to not allow the Start button to be accepted unless the Input boxes are filled?

I found the needed info.

Edited by Cwelle
Link to comment
Share on other sites

This was great help Thank you very much.

I was wondering though with the same code above is it possible to not allow the Start button to be accepted unless the Input boxes are filled?

I found the needed info.

It's nice to also put in the solution u found;)

as finishing touch god created the dutch

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...