Jump to content

Interview style GUI creation - (Moved)


Recommended Posts

I don't know if Auto IT is a the correct tool to do this but thought I would post this question.

I am trying create to create an interview type flow.  The initial GUI would be generic and based on the response you would get a new GUI with additional data. It would be a decision tree the user can use to find a likely response to a series of questions.

Trying to make it so that it uses a simple input file or INI file so people could add their own question / answer responses.

 

High Level example of what I am trying.

GUI-1

Are you a Dog or a Cat?

          GUI2.1 Dog - show another GUI with additional quesion

                       Is you dog a puppy?

                                GUI2.2 Show another GUI with question      

                                        repeat with more GUI's until end .......................

         GUUI3.1 Cat - show another GUI with additional question 

                        Is you cat a calico?

                               GUI3.2 Show another GUI with question      

                                        repeat with more potential GUI's until end .......................

 

It is a decision interview where based on what they answer a new GUI is show with new questions as well as tips.

Hope this make sense.  If not I am sure you will let me know.

Was thing of creating the GUI and then reading in an INI file.  The INI file would have a start reference and and next reference.  That way I can have it scale and make it easy for users to add questions.

 

Is Auto IT the toll taht could create this?  Needs to be small, standalone, and new entries simplified.

 

Any response would be appreciated.

 

Thx

Link to comment
Share on other sites

OK I will start clicking away .

 

I assume I would read the INI into an array to speed it up.  Comment?

use of single INI or multiple INI files?  Because the INI is limited to a 64K files size this would likely be more scalable.  Comment?

GUI title base on INI variable?  Think this would be the cleanest  Comment?

I know the questions may seem basic but before I go off on a coding tangent I wanted to have my ducks in a row.

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum.

Moderation Team

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

..it'd be better to use SQLite as the database as it can do so much more than an INI file.
I'd put parts of the gui in the database. In this way you can have the questions, answers flow and gui changes you may feel needed without recompiling.
Now using a db ( database ), can be anything so the ini idea is a plain text, easy on the brain idea but, if you start using a db engine, in this case SQLite, you'll be able to do much more at the low cost ( joke, it's quite a transition ) of getting used to _SQLite_GetTable2D() instead of IniRead().
Do pardon the prior response but I usually find those that post an idea and don't ever come back to the forum.

Anything I can help with, I'll be watching this thread :) 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Appreciate the feedback.

You are correct about the sql source data.  A lot more work because I would need to include a method the add / edit the questions.  Much more effective but it will take me a bit to get up to speed on sql. And I would need to grow a brain to do that.

What are you thoughts about starting with an INI file and then migrating to sql?  Is that a waste of time and should I just bite the bullet and start off with sql?

That way I could get the GUI and workflow ironed out.

Link to comment
Share on other sites

I played with it a bit

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

Global $sMyIni = @ScriptDir & "\Quest.ini"
Global $Radio[3] = [2, 1, 2]
Global $Choose[3] = [2, 1, 2]

GUICreate("Quest", 400, 170, -1, -1)

Global $lQuest = GUICtrlCreateLabel("Label1", 40, 10, 390, 22)
GUICtrlSetFont(-1, 11, 400, 0, "Tahoma")

GUICtrlCreateGroup("Choose", 30, 40, 311, 81)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")

$Radio[1] = GUICtrlCreateRadio("Radio1", 40, 60, 97, 17)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$Radio[2] = GUICtrlCreateRadio("Radio2", 40, 90, 97, 17)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $ButtonNext = GUICtrlCreateButton("Nex", 150, 130, 100, 25)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
GUICtrlSetState(-1, $GUI_DISABLE)

SetDataFromSection("Are you a Dog or a Cat")

GUISetState(@SW_SHOW)

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

        Case $ButtonNext
            If GUICtrlRead($ButtonNext) = "Close" Then Exit

            If BitAND(GUICtrlRead($Radio[1]), $GUI_CHECKED) = $GUI_CHECKED  Then
                SetDataFromSection($Choose[1])
            ElseIf BitAND(GUICtrlRead($Radio[2]), $GUI_CHECKED) = $GUI_CHECKED  Then
                SetDataFromSection($Choose[2])
            EndIf

            GUICtrlSetState($Radio[1], $GUI_UNCHECKED)
            GUICtrlSetState($Radio[2], $GUI_UNCHECKED)

        Case $Radio[1], $Radio[2]
            GUICtrlSetState($ButtonNext, $GUI_ENABLE)

    EndSwitch
WEnd
;***************************************************

Exit

;----------------------------------------------------------------------------------------
Func SetDataFromSection($Section)
    GUICtrlSetData($lQuest, $Section)

    Local $aArray = IniReadSection($sMyIni, $Section)
        ;$aArray[1][0] = 1st Key
        ;$aArray[1][1] = 1st Value

    If Not @error Then
        For $i = 1 To $aArray[0][0]
            If $aArray[$i][1] Then
                GUICtrlSetData($Radio[$i], $aArray[$i][0])
                $Choose[$i] = $aArray[$i][1]
            Else
                GUICtrlSetState($Radio[$i], $GUI_HIDE)
                GUICtrlSetData($ButtonNext, "Close")
            EndIf
        Next
    EndIf

EndFunc   ;==>SetDataFromSection
;----------------------------------------------------------------------------------------

 

the Quest.ini

[Are you a Dog or a Cat]
Dog=Is you dog a puppy
Cat=Is you cat a calico

[Is you dog a puppy]
Yes=what do you like more
No=Is you dog a shepherd

[Is you cat a calico]
Yes=what do you like more
No=Is you cat a Siam

[Is you dog a shepherd]
Yes=what do you like more
No=Is you dog a guardian

[Is you dog a guardian]
Yes=what do you like more
No=what do you like more

[Is you cat a Siam]
Yes=what do you like more
No=Is you cat a Persian

[Is you cat a Persian]
Yes=what do you like more
No=what do you like more

[what do you like more]
Play=your Play is over
ride=your ride is over

[your ride is over]
1=
2=

[your Play is over]
1=
2=

 

I know that I know nothing

Link to comment
Share on other sites

I was playing this (in my thoughts) through, and came to the conclusion that you should check if an answer (ini section) already exists before adding something new.

if you simply add, you may overwrite the old answer with a new question and the sequential logic may break at some time.

 

edit: 

Quote

What are you thoughts about starting with an INI file and then migrating to sql 

Ini file is just fine. If you go with the ini, you can easily spot the mistakes.
when you are 100% sure that there are no mistakes, then you can convert it to the sql (if you think that the ini file is limiting in some way).

If you manage to set the reading/editing/writing the data into functions, then you only need to rewrite the functions and to point them to the sql instead of the ini.

Edited by Dan_555

Some of my script sourcecode

Link to comment
Share on other sites

After @Dan_555 suggestion :)

; https://www.autoitscript.com/forum/topic/209945-interview-style-gui-creation-moved/?do=findComment&comment=1515664

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

Global $sMyIni = @ScriptDir & "\Quest.ini"
Global $Radio[3] = [2, 1, 2]
Global $Choose[3] = [2, 1, 2]

CheckMyIni()

GUICreate("Quest", 400, 170, -1, -1)

Global $lQuest = GUICtrlCreateLabel("Label1", 40, 10, 390, 22)
GUICtrlSetFont(-1, 11, 400, 0, "Tahoma")

GUICtrlCreateGroup("Choose", 30, 40, 311, 81)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")

$Radio[1] = GUICtrlCreateRadio("Radio1", 40, 60, 97, 17)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$Radio[2] = GUICtrlCreateRadio("Radio2", 40, 90, 97, 17)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $ButtonNext = GUICtrlCreateButton("Nex", 150, 130, 100, 25)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
GUICtrlSetState(-1, $GUI_DISABLE)

SetDataFromSection("Are you a Dog or a Cat")

GUISetState(@SW_SHOW)

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

        Case $ButtonNext
            If GUICtrlRead($ButtonNext) = "Close" Then Exit

            If BitAND(GUICtrlRead($Radio[1]), $GUI_CHECKED) = $GUI_CHECKED Then
                SetDataFromSection($Choose[1])
            ElseIf BitAND(GUICtrlRead($Radio[2]), $GUI_CHECKED) = $GUI_CHECKED Then
                SetDataFromSection($Choose[2])
            EndIf

            GUICtrlSetState($Radio[1], $GUI_UNCHECKED)
            GUICtrlSetState($Radio[2], $GUI_UNCHECKED)

        Case $Radio[1], $Radio[2]
            GUICtrlSetState($ButtonNext, $GUI_ENABLE)

    EndSwitch
WEnd
;***************************************************

Exit

;----------------------------------------------------------------------------------------
Func SetDataFromSection($Section)
    GUICtrlSetData($lQuest, $Section)

    Local $aArray = IniReadSection($sMyIni, $Section)
    ;$aArray[1][0] = 1st Key
    ;$aArray[1][1] = 1st Value

    If Not @error Then
        For $i = 1 To $aArray[0][0]
            If $aArray[$i][1] Then
                GUICtrlSetData($Radio[$i], $aArray[$i][0])
                $Choose[$i] = $aArray[$i][1]
            Else
                GUICtrlSetState($Radio[$i], $GUI_HIDE)
                GUICtrlSetData($ButtonNext, "Close")
            EndIf
        Next
    EndIf

EndFunc   ;==>SetDataFromSection
;----------------------------------------------------------------------------------------
Func CheckMyIni()
    ; Read the INI section names. This will return a 1 dimensional array.
    Local $aSection = IniReadSectionNames($sMyIni)
    Local $sMsg

    ; Check if an error occurred.
    If Not @error Then
        ; Enumerate through the array displaying the section names.
        For $i = 1 To $aSection[0]
            ;ConsoleWrite("Section: " & $aSection[$i] & @CRLF)
        Next
    EndIf

    For $x = 1 To $aSection[0]
        For $z = 1 To $aSection[0]
            If $aSection[$x] = $aSection[$z] Then
                If $x <> $z Then
                    $sMsg = $aSection[$z] & @CRLF & @CRLF
                    $sMsg &= "collide sections " & $x & ", " & $z & @CRLF & @CRLF
                    $sMsg &= "Please fix it to avoid complications"

                    MsgBox(4144, "Dublicate Section found", $sMsg)

                    ShellExecute($sMyIni)
                    Exit

                EndIf
            EndIf
        Next
    Next
EndFunc   ;==>CheckMyIni

 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

I had already created my GUI and had the basic flow working minus the INI section read. However thanks for your suggestion.  I am working on the INI piece now so you response insightful.  It gave me a different prospective.

Think I will grind some code and see if I get struck.  If I do I will definitely ask you guys for feedback.

Thx

 

 

Edited by IvanCodin
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...