Jump to content

please help me


 Share

Recommended Posts

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

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

  • Moderators

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

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

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

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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.

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

Link to comment
Share on other sites

  • Developers

Just: read the content of the control with GuiCtrlRead(), strip the one character and put the string back with GuiCtrlSetData().

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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.

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