ronaldo97

please help me

11 posts in this topic

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



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

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

 

1 person likes this

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
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

Share this post


Link to post
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

 

1 person likes this

I'm pretty sure this script has "some flaws" (somewhere). Welcome to programming!

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

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

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.

1 person likes this

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

Share this post


Link to post
Share on other sites

I want to Delete  A single letter !!

Share this post


Link to post
Share on other sites

#10 ·  Posted

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

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#11 ·  Posted

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