Jump to content

Button Variables Creation


Recommended Posts

Hello,

 

I need this for a project and I don't find a method for the next problem.

I want when I click a button to create a variable ("$variable1") so if I press one more time to create one more ("$variable2") and create more and more how many times you press the button.

 

Do you have an idea ? 

Thank you for your attention !

Link to comment
Share on other sites

  • Moderators

AppSoftwareVld,

Welcome to the AutoIt forums.

You could use an array and add an element each time you click the button. But if you could explain why you need to create these variables, we might be able to offer better solutions.

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

It's a bit difficult what I want to do, when the button click he will create a variable and set the variable some data.

Actually, there is one more problem, probably I will open in another topic.

After that I want to show on a list all variables that have a selected data (example show all variables with 'blue' data) or something like that.

 

Sorry for my bad english, I hope you understood what I want to do.

Link to comment
Share on other sites

  • Moderators

AppSoftwareVld,

That is simply a repeat of what you want to do - I was asking why you wanted to do it, for example what type of data are you storing with each button press?

If you were to use the array method I suggested then your second problem can be solved by searching through the array for the necessary "key" and then adding those elements to a List control. Again, if you can explain more clearly just what you are trying to do then I can offer more focused help.

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

I don't speak so good english, but all I want to do is when click the button read an input, create a new variable where that will have the text from the input and when i click on another button show a combo with all  the variables that have the text 'blue'.

 

I don't want to do nothing with them just show them in a combo.

If you don't understand you can enter with team viewer if you have time to help for a moment and show you what I actually want to do, I can't explain so good in english.

Link to comment
Share on other sites

  • Moderators

AppSoftwareVld,

Does this do what you want?

#include <GUIConstantsEx.au3>

; Array to hold input contents
Global $aContents[1] = [0]

; Set required string to match
$sRequired = "blue"

; Create GUI
$hGUI = GUICreate("Test", 500, 500)

$cInput = GUICtrlCreateInput("", 10, 10, 200, 20)

$cRead = GUICtrlCreateButton("Read", 10, 50, 80, 30)

$cShow = GUICtrlCreateButton("Show", 100, 50, 80, 30)

$cCombo = GUICtrlCreateCombo("", 10, 100, 200, 200)
GUICtrlSetState($cCombo, $GUI_HIDE)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cRead
            ; Increase size of array
            $aContents[0] += 1
            ReDim $aContents[$aContents[0] + 1]
            ; Check if there is something to add
            If GUICtrlRead($cInput) <> "" Then
                ; Add input contents to array
                $aContents[$aContents[0]] = GUICtrlRead($cInput)
            EndIf
            ; Clear input
            GUICtrlSetData($cInput, "")
            ; Reset focus to input
            GUICtrlSetState($cInput, $GUI_FOCUS)
        Case $cShow
            ; Create new combo data
            $sComboData = ""
            ;Loop through array
            For $i = 1 To $aContents[0]
                ; Check if required value is present
                If StringInStr($aContents[$i], $sRequired) Then
                    ; And add to combo data
                    $sComboData &= "|" & $aContents[$i]
                EndIf
            Next
            ; Add data to combo
            GUICtrlSetData($cCombo, $sComboData)
            ; Show combo
            GUICtrlSetState($cCombo, $GUI_SHOW)
        Case $cCombo
            GUICtrlSetState($cCombo, $GUI_HIDE)



    EndSwitch

WEnd

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

  • Moderators

AppSoftwareVld,

Glad I could help.

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

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

×
×
  • Create New...