Jump to content
ronaldo97

please help me

Recommended Posts

ronaldo97
Hi guys :)
I am making the interface to program

containing 1 input and 2 Button

button 1 to print text " Hello "

and a button 2  to print " World" in input

the question is : What is the code that makes the second text written after the first text without delete first text

Experimented @Lf and @Cr and @crlf  But does not work :( .

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 451, 241, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 120, 136, 113, 33)
$Button2 = GUICtrlCreateButton("Button2", 248, 136, 145, 33)
$Input1 = GUICtrlCreateInput("", 112, 80, 257, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            GUICtrlSetData ($Input1,"Hello")
        case $Button2
            GUICtrlSetData ($Input1,"World")
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites
ronaldo97
Just now, ronaldo97 said:

Hi guys :)
I am making the interface to program

containing 1 input and 2 Button

button 1 to print text " Hello " in input

and a button 2  to print " World" in input

the question is : What is the code that makes the second text written after the first text without delete first text


Experimented @Lf and @Cr and @crlf  But does not work :( .

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 451, 241, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 120, 136, 113, 33)
$Button2 = GUICtrlCreateButton("Button2", 248, 136, 145, 33)
$Input1 = GUICtrlCreateInput("", 112, 80, 257, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            GUICtrlSetData ($Input1,"Hello")
        case $Button2
            GUICtrlSetData ($Input1,"World")
    EndSwitch
WEnd

 

 

Share this post


Link to post
Share on other sites
JLogan3o13

Why are you bumping your post after 4 minutes? You need  to wait at least 24 hours before bumping. You can do something like this:

#include <GUIConstantsEx.au3>
Local $sText = ""
$Form1 = GUICreate("Form1", 451, 241, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 120, 136, 113, 33)
$Button2 = GUICtrlCreateButton("Button2", 248, 136, 145, 33)
$Input1 = GUICtrlCreateInput("", 112, 80, 257, 21)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            $sText &= "Hello"
            GUICtrlSetData ($Input1, $sText)
        case $Button2
            $sText &= " World"
            GUICtrlSetData ($Input1, $sText)
    EndSwitch
WEnd

 

  • Like 1

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
kylomas

or...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 451, 241, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 120, 136, 113, 33)
$Button2 = GUICtrlCreateButton("Button2", 248, 136, 145, 33)
$Input1 = GUICtrlCreateInput("", 112, 80, 257, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Input1, "Hello")
        Case $Button2
            GUICtrlSetData($Input1, GUICtrlRead($Input1) & " World")
    EndSwitch
WEnd

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
ripdad

or...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 451, 241, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 120, 136, 113, 33)
$Button2 = GUICtrlCreateButton("Button2", 248, 136, 145, 33)
$Input1 = GUICtrlCreateInput("", 112, 80, 257, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            GUICtrlSetData($Input1,"Hello", 1); <--
        case $Button2
            GUICtrlSetData($Input1,"World", 1); <--
    EndSwitch
WEnd

 

  • Like 1

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites
ronaldo97
6 hours ago, ripdad said:

or...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 451, 241, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 120, 136, 113, 33)
$Button2 = GUICtrlCreateButton("Button2", 248, 136, 145, 33)
$Input1 = GUICtrlCreateInput("", 112, 80, 257, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            GUICtrlSetData($Input1,"Hello", 1); <--
        case $Button2
            GUICtrlSetData($Input1,"World", 1); <--
    EndSwitch
WEnd

 

thank you very much  thank you very much  thank you very much  !! :D:D  

The problem was the number ,1 did not add it at the end :lol:

Share this post


Link to post
Share on other sites
ronaldo97

What is the code for the Delete only one text ?? 

 

Example 

case $Button1
            GUICtrlSetData($Input1,"Hello", 1)
        case $Button2
            GUICtrlSetData($Input1,"World", 1)
            
          
            case $Button3
            ;I want this Delete just one text only !!

 

Share this post


Link to post
Share on other sites
SadBunny

What do you mean by "only one text"? A single letter, a single word, a single line, something else?

Note that your "1" makes the system add something to whatever is in the input. If you want to change what's in that input, you'll have to replace what's in there by what you want to put in there. The most flexible one is to read what's in there (GUICtrlRead) into a variable, then do magic with that content, then put the result back in there (GUICtrlSetData). Flexible because in that way you can work with user input.

  • Like 1

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
ronaldo97

I want to Delete  A single letter !!

Share this post


Link to post
Share on other sites
SadBunny

Here's a fun little demo :) 

; press ESC to exit
HotKeySet("{ESC}", "exitNow")

; build gui
$gui = GUICreate("hi there")
$input1 = GUICtrlCreateInput("Type anything in these input controls!", 10, 10)
$input2 = GUICtrlCreateInput("every second, a random character", 10, 40)
$input3 = GUICtrlCreateInput("will be deleted from each field", 10, 70)
GUISetState()

; neverending loop
While True
    Sleep(1000)
    deleteRandomLetter($input1)
    deleteRandomLetter($input2)
    deleteRandomLetter($input3)
WEnd

; the magic
Func deleteRandomLetter(ByRef $inputControl)
    $text = GUICtrlRead($inputControl)
    ConsoleWrite($text & @CRLF)
    $length = StringLen($text)
    $indexOfCharToRemove = Random(1, $length, 1)
    $newText = StringLeft($text, $indexOfCharToRemove - 1) & StringRight($text, $length - $indexOfCharToRemove)
    GUICtrlSetData($inputControl, $newText)
EndFunc   ;==>deleteRandomLetter

; function called when you press ESC
Func exitNow()
    Exit
EndFunc   ;==>exitNow

 


Roses are FF0000, violets are 0000FF... All my base are belong to you.

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

×