Jump to content

Getting two GUICtrlCreateInput shown up in one GUICtrlCreateEdit


IDN
 Share

Recommended Posts

Hello Guys,

I am new here. I hope you can understand my Porblems

I have crated two GUIInput lines and i just want two join them together so that i will have in my Edit Box all the information of those (but I want a version where it dosen't matter if will join five or ten or twenty, so that would be very helpful to me. Of corsue the input's will set in the Edit box by a button Click.

Here is what i tryied.

case $button1
               GUICtrlSetData($Edit1, GUICtrlRead ($Input1 & Input2)) but that dosent work really. when i want only to show input1 then works perfectly.

I also have a another problem when i want to add something to the Input when i click that button then i only can add something after the input like this.

case $button1
               GUICtrlSetData($Edit1, GUICtrlRead ($Input1) & "great")  this version works good i get and output of $input1great

but if i try this

               GUICtrlSetData($Edit1, GUICtrlRead ( "great" & ($Input1) ) ) this dosent work i want an output in my edit of great$Input1.

I just can't figure these Problems out. But the main problem ist to join two GUICtrlCreateInput's together.

 

I thought  maybe i could work with consoleWrite, but then i need a function that tells consoleWrite to write in the edit box.

Thanks for your fiendly help.

 

Link to comment
Share on other sites

Now i tried this:

case $button
               GUICtrlSetData($Edit1, GUICtrlRead ($Inputx ) And GUICtrlRead($Inputy))

but still dosent work.

in my edit its showing just the word "true" i just dont get it.

Link to comment
Share on other sites

Try :

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $idInput1, $idInput2, $idBtn, $sAllInputs = ""

    $hGUI = GUICreate("Example", 400, 200)

    $idInput1 = GUICtrlCreateInput("", 10, 5, 300, 20)
    $idInput2 = GUICtrlCreateInput("", 10, 35, 300, 20)
    $idBtn    = GUICtrlCreateButton("Ok", 40, 75, 60, 20)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtn
                $sAllInputs = GUICtrlRead($idInput1) & GUICtrlRead($idInput2)
                MsgBox(0, "Input1 + Input2", "Inputfields = " & $sAllInputs)

        EndSwitch
    WEnd
EndFunc   ;==>Example

Oh, and welcome to the forum ;).

 

@IDN EDIT : Example with an Edit control :

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

Example()

Func Example()
    Local $hGUI, $idInput1, $idInput2, $idEdit1, $idBtn

    $hGUI     = GUICreate("Example", 600, 400)
    $idInput1 = GUICtrlCreateInput("", 20, 10, 300, 25)
    $idInput2 = GUICtrlCreateInput("", 20, 50, 300, 25)
    $idEdit1  = GUICtrlCreateEdit("", 20, 100, 300, 200, $ES_AUTOVSCROLL + $WS_VSCROLL)
    $idBtn    = GUICtrlCreateButton("Ok", 20, 350, 100, 25)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtn
                GUICtrlSetData($idEdit1, GUICtrlRead($idInput1) & GUICtrlRead($idInput2))
        EndSwitch
    WEnd
EndFunc   ;==>Example

 

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Hey, Musashi,

I love this, it´s working now. I would like to hug you, just awsome. I never expected an answer that fast; awsome.

i just have now another qestion i know how to take the $idInput2 in a new line but i want a blankspace beetwen them how do i do that. I can not find a code like @CRLF.

 

Thanks I am so happy, for your help.

 

 

Link to comment
Share on other sites

3 minutes ago, IDN said:

Hey, Musashi,

I love this, it´s working now. I would like to hug you, just awsome.

Just for the record : I've already got a girlfriend :lol:.

8 minutes ago, IDN said:

but i want a blankspace beetwen them how do i do that.

Use :

GUICtrlSetData($idEdit1, GUICtrlRead($idInput1) & Chr(32) & GUICtrlRead($idInput2))

or

GUICtrlSetData($idEdit1, GUICtrlRead($idInput1) & " " & GUICtrlRead($idInput2))

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Thanks yes it worked.

2 minutes ago, Musashi said:

Just for the record : I've already got a girlfriend :lol:. 

Dont worry i also have a Girlfriend 😅

but thanks for your help, just asome.

I am working on a projekt. I hope you still want to chat about my problems.

man i love this forum just from the begining.

Link to comment
Share on other sites

9 minutes ago, IDN said:

I am working on a projekt. I hope you still want to chat about my problems.

Within the forum, no problem.

Additional note, since you are a new member :

AutoIt has an excellent help system. Many people have invested tons of time to create it. It would be a good idea to familiarize yourself with it. Within the SciTE editor, for example, click with the cursor on a command and press F1 (the script must have been saved once before).

Don't be afraid to post a script next time, even if it doesn't work. This is often more convenient than reading through a wall of text ;).

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Okay I will do so in the next time and post the hole thing.

I have a question with Checkboxes i have here the script from you and added some checkboxes and i just want to klick the checkbox 1 and then it schould write a  text in my edit.

but something is wrong here.

 

Thank you for your helps and for your tipps.

 

Here the hole thing:

 

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

Example()

Func Example()
    Local $hGUI, $idInput1, $idInput2, $idEdit1, $idBtn

    $hGUI     = GUICreate("Example", 600, 400)
    $idInput1 = GUICtrlCreateInput("", 20, 10, 300, 25)
    $idInput2 = GUICtrlCreateInput("", 20, 50, 300, 25)
    $idCheck1 = GUICtrlCreateCheckbox("Checkbox 1", 350, 15, 100, 17)
    $idCheck2 = GUICtrlCreateCheckbox("Checkbox 2", 350, 45, 100,17)
    $idEdit1  = GUICtrlCreateEdit("", 20, 100, 300, 200, $ES_AUTOVSCROLL + $WS_VSCROLL)
    $idBtn    = GUICtrlCreateButton("Ok", 20, 350, 100, 25)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtn
                GUICtrlSetData($idEdit1, GUICtrlRead($idInput1) & GUICtrlRead($idInput2) &
                If GUICtrlRead($idCheck1) = 1, Then & "Hello")

        EndSwitch
    WEnd
EndFunc   ;==>Example

Link to comment
Share on other sites

38 minutes ago, IDN said:

i just want to klick the checkbox 1 and then it should write a text in my edit.

Do you mean something like this ? :

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


Example()

Func Example()
    Local $hGUI, $idInput1, $idInput2, $idEdit1, $idBtn, $idCheck1, $idCheck2

    $hGUI     = GUICreate("Example", 600, 400)
    $idInput1 = GUICtrlCreateInput("", 20, 10, 300, 25)
    $idInput2 = GUICtrlCreateInput("", 20, 50, 300, 25)
    $idCheck1 = GUICtrlCreateCheckbox("Checkbox 1", 350, 15, 100, 17)
    $idCheck2 = GUICtrlCreateCheckbox("Checkbox 2", 350, 45, 100,17)
    $idEdit1  = GUICtrlCreateEdit("", 20, 100, 300, 200, $ES_AUTOVSCROLL + $WS_VSCROLL)
    $idBtn    = GUICtrlCreateButton("Ok", 20, 350, 100, 25)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idBtn
                GUICtrlSetData($idEdit1, GUICtrlRead($idInput1) & GUICtrlRead($idInput2))

            Case $idCheck1
                If BitAND(GUICtrlRead($idCheck1), $BN_CLICKED) = $BN_CLICKED Then
                    If _GUICtrlButton_GetCheck($idCheck1) Then
                        ConsoleWrite("> >>> $idCheck1 checked ... " & @CRLF)
                        GUICtrlSetData($idEdit1, GUICtrlRead($idInput1) & Chr(32) & GUICtrlRead($idInput2))
                    Else
                        ConsoleWrite("> >>> $idCheck1 unchecked ... " & @CRLF)
                    EndIf
                EndIf

        EndSwitch
    WEnd
EndFunc   ;==>Example

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

I don't know why but i cant get your script running.

But i have forgotten an important information i want that if i click button $idBtn that the Check box will be read and an definition text from the checkbox schould be appear in the edit. I hope you can understand what i want.

Thank you.

Link to comment
Share on other sites

I got it running there was an "?" after" Wend" i dont't know why but dosent matter.

That is quite cool but not exactly what i wanted i want the inputs as they are and the if i click the checkbox and click after that OK then i schoul write an text in the edit like "Awesome" or something.

Thanks

Link to comment
Share on other sites

52 minutes ago, IDN said:

I got it running there was an "?" after" Wend" i dont't know why

This sometimes happens, when you Copy&Paste code from the forum. I have attached the example as a file too.

BTW : I suggest you reconsider your concept. Using a checkbox to add text may not be the best approach.

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

Example()

Func Example()
    Local $hGUI, $idInput1, $idInput2, $idEdit1, $idBtnOk, $idBtnReset, $idCheck1, $idCheck2

    $hGUI       = GUICreate("Example", 600, 400)
    $idInput1   = GUICtrlCreateInput("", 20, 10, 300, 25)
    $idInput2   = GUICtrlCreateInput("", 20, 50, 300, 25)
    $idCheck1   = GUICtrlCreateCheckbox("Checkbox 1", 350, 15, 100, 17)
    $idCheck2   = GUICtrlCreateCheckbox("Checkbox 2", 350, 45, 100,17)
    $idEdit1    = GUICtrlCreateEdit("", 20, 100, 300, 200, $ES_AUTOVSCROLL + $WS_VSCROLL)
    $idBtnOk    = GUICtrlCreateButton("Ok", 20, 350, 100, 25)
    $idBtnReset = GUICtrlCreateButton("Reset", 140, 350, 100, 25)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idBtnOk
                If BitOR(GUICtrlRead($idInput1) == "", GUICtrlRead($idInput2) == "") Then
                    ConsoleWrite("> >>> Inputs are empty ... " & @CRLF)
                Else
                    ConsoleWrite("> >>> Inputs are not empty ... " & @CRLF)
                    GUICtrlSetData($idEdit1, GUICtrlRead($idEdit1) & GUICtrlRead($idInput1) & Chr(32) & GUICtrlRead($idInput2))
                EndIf

            Case $idBtnReset
                GUICtrlSetData($idEdit1, "")


            Case $idCheck1
                If BitAND(GUICtrlRead($idCheck1), $BN_CLICKED) = $BN_CLICKED Then
                    If _GUICtrlButton_GetCheck($idCheck1) Then
                        ConsoleWrite("> >>> $idCheck1 checked ... " & @CRLF)
                        GUICtrlSetData($idEdit1, GUICtrlRead($idEdit1) & "Awesome")
                    Else
                        ConsoleWrite("> >>> $idCheck1 unchecked ... " & @CRLF)
                    EndIf
                EndIf

        EndSwitch
    WEnd
EndFunc   ;==>Example

 

Checkbox-Test2.au3

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

This is very good and nearly what i wanted. I will describe you what i am doing so you have a better Idea what i want to do and it may easier to understand what i want.

I am writting something like a customersurface were you can put informations in input boxes or check a checkbox and when you click okay all these informations schould be added to the editbox so its like some kind of dialog.

So this script you send is nearly perfect only one thing is what i want to change and that is to click okay and only then the informations will be added to the edit box because it is important in witch sequence the informations appear. ( I mean it makes scenes to me that the name comes first and then age and so on.

Hope you understand what I want to do.

Thanks a lot. I'm glad for your help.

Link to comment
Share on other sites

59 minutes ago, IDN said:

Hope you understand what I want to do.

I'm getting closer :lol:.

It would be a great help for you (and others) to outline the design of your input mask. This means : Which fields are required? How should the fields be labelled (Name, Age, DOB ... )?

E.G. : Instead of naming a button "OK", something like "Combine fields" would be a better description.

A checkbox that inserts a text into the edit field in real time makes little sense. It is better suited to set yes/no states, e.g. "smoker" or "older than 18". A selectbox would be suitable for a selection among several texts etc..

Just make a list of the desired elements, and please not so much text 😛.

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Of corse I outline the design. This is what i had in mind, i think some things must be changend but if that will run then i think it would be great and i can change things or add things.

I hope my naming vor the variabels is not that bad. So i just wanna typ an all these thinks an check the checkboxes and in the end click summarize Input and everthing is shown up in the edit that is what i want to get.

so here is my design.

Thanks a lot.

 

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Mask = GUICreate("Mask", 613, 456, 224, 111)
$lfirsname = GUICtrlCreateLabel("First Name", 48, 24, 54, 17)
$lname = GUICtrlCreateLabel("Name", 48, 56, 32, 17)
$ifirstname = GUICtrlCreateInput("", 112, 16, 121, 21)
$iname = GUICtrlCreateInput("", 112, 48, 121, 21)
$cmale = GUICtrlCreateCheckbox("Male", 56, 144, 97, 17)
$cfemale = GUICtrlCreateCheckbox("Female", 160, 144, 97, 17)
$lgender = GUICtrlCreateLabel("Gender", 48, 112, 39, 17)
$lcountry = GUICtrlCreateLabel("Country of origin", 48, 184, 80, 17)
$icountry = GUICtrlCreateInput("", 56, 208, 121, 21)
$Checkbox2 = GUICtrlCreateCheckbox(">20", 160, 296, 97, 17)
$Checkbox1 = GUICtrlCreateCheckbox("<20", 56, 296, 97, 17)
$lage = GUICtrlCreateLabel("Age", 48, 272, 23, 17)
GUICtrlCreateEdit("", 344, 56, 185, 289)
$Button1 = GUICtrlCreateButton("Summarize Input", 168, 400, 115, 25)
$bcancel = GUICtrlCreateButton("Cancel", 40, 400, 75, 25)
$bsave = GUICtrlCreateButton("Save Input", 368, 368, 123, 25)
$loverview = GUICtrlCreateLabel("Overview", 344, 24, 49, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd

 

Customer surface.au3

Link to comment
Share on other sites

4 hours ago, dmob said:

Instead of using checkbox for gender, have a look at GUICtrlCreateRadio

I fully agree !

Although it is possible to use checkboxes, radio buttons are by far the better option.

@IDN :

Here is a simple example with three variations:

#include <GUIConstantsEx.au3>

GUICreate("Demos :", 400, 350)
Global $idCheck1 = GUICtrlCreateCheckbox("Male", 20, 20, 100, 20)
Global $idCheck2 = GUICtrlCreateCheckbox("Female", 20, 50, 100, 20)
GUICtrlSetState($idCheck1, $GUI_CHECKED)
Global $idRadio1 = GUICtrlCreateRadio("Male", 20, 100, 100, 20)
Global $idRadio2 = GUICtrlCreateRadio("Female", 20, 130, 100, 20)
GUICtrlSetState($idRadio1, $GUI_CHECKED)

Global $idGroupGender = GUICtrlCreateGroup("Gender : ", 20, 170, 120, 100)
Global $idGroupRadio1 = GUICtrlCreateRadio("Male ", 30, 200, 100, 20)
Global $idGroupRadio2 = GUICtrlCreateRadio("Female", 30, 230, 100, 20)
GUICtrlSetState($idGroupRadio1, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1) ; close group

Global $idBtnOk = GUICtrlCreateButton("Ok", 20, 300, 80, 25)

GUISetState()

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

        Case $idCheck1
            GUICtrlSetState($idCheck1, $GUI_CHECKED)
            GUICtrlSetState($idCheck2, $GUI_UNCHECKED)

        Case $idCheck2
            GUICtrlSetState($idCheck2, $GUI_CHECKED)
            GUICtrlSetState($idCheck1, $GUI_UNCHECKED)

        Case $idBtnOk
            MsgBox(4096, "Summary", "idCheck1 =" & GUICtrlRead($idCheck1) & @CRLF & _
                                    "idCheck2 =" & GUICtrlRead($idCheck2) & @CRLF & _
                                    "idRadio1 =" & GUICtrlRead($idRadio1) & @CRLF & _
                                    "idRadio2 =" & GUICtrlRead($idRadio2) & @CRLF & _
                                    "idGroup1 =" & GUICtrlRead($idGroupRadio1) & @CRLF & _
                                    "idGroup2 =" & GUICtrlRead($idGroupRadio2) & @CRLF)
            ExitLoop

    EndSwitch
WEnd

Short question : Which entries may appear in the field "Country of origin"? A selected or a worldwide list of countries? A ComboBox might be useful.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Great thanks for your help it really helps me a lot and now i have what i want. But there is another thing that i am ciriuos about now i am searching for away that when i have a text a long text that i can write a programm that adds me all line numbers. hope you know what i want.

 

Link to comment
Share on other sites

Example:

bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla

 

CLICK

 

1 bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla 2 bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla 3 bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla 4 bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla

 Thanks for your help it is really really really awsome.

 

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