senatin

ControlGetText How to use to get Last text in createEdit?

7 posts in this topic

#1 ·  Posted (edited)

Sorry for asking simple problem
I tried looking arround but I could not find the right one.

My problem is that I created A GUI with GUICtrlCreateEdit then along with the script it keep on adding new lines
What I wanted to happen is that when I insert new text line and it is the same as the last line, it will not insert to the field.

Thank you

Edited by senatin

Share this post


Link to post
Share on other sites



#2 ·  Posted

senatin,

I would read the content of the edit, split it into an array and then compare the "to-be-added" text to the last element of that array.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

is it a bit stressful to Ram? if so I rather not apply. 
my script add many lines when it run. so whenever I add lines it keep on splitting into array all the contents.

Edited by senatin

Share this post


Link to post
Share on other sites

#4 ·  Posted

9 minutes ago, senatin said:

is it a bit stressful to Ram? if so I rather not apply. 
my script add many lines when it run. so whenever I add lines it keep on splitting into array all the contents.

It is a bit difficult to tell you how badly your script will tax resources without seeing the script. Post the script (or a reproducer) if you would like some further assistance, or just try the suggestion given by Melba for yourself if you are unable to post.


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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

HotKeySet ("-", "SendNum")

#Region ### START Koda GUI section ### Form=c:\users\mk's\desktop\form1.kxf
$Form1 = GUICreate("Senatin", 615, 438, 178, 132)
$Edit1 = GUICtrlCreateEdit("", 40, 96, 361, 257)
$Input1 = GUICtrlCreateInput("20", 440, 136, 49, 21, $ES_NUMBER)


While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Turnoff()
            
    EndSwitch
    
    
Wend

Func SendNum()
    $num1 = GUICtrlRead($Input1)
    $Lasttxt = ControlGetText("", "", "Edit1")
    If($num1 <> $Lasttxt) then
        InsertText($num1)
    Endif
EndFunc
    
Func InsertText($text)
    GUICtrlSetData($Edit1, @CRLF & $text, 1)
EndFunc
   
    
Func Turnoff()
   Exit
EndFunc

 

Edited by senatin
I notice shoudnt be == rather <> still not working

Share this post


Link to post
Share on other sites

#6 ·  Posted

senatin,

As you are reading the number from a control in your own GUI, just store the last entered one and compare - like this:

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

HotKeySet ("-", "SendNum")

$Form1 = GUICreate("Senatin", 615, 438, 178, 132)
$Edit1 = GUICtrlCreateEdit("", 40, 96, 361, 257)
$Input1 = GUICtrlCreateInput("20", 440, 136, 49, 21, $ES_NUMBER)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Turnoff()
    EndSwitch
Wend

Func SendNum()

    ; Store the last added line
    Static Local $iLastNum = ""
    ; Get the new one
    $num1 = GUICtrlRead($Input1)
    ; Check for the same value
    If $num1 <> $iLastNum then
        ; Insert the new value
        InsertText($num1)
        ; Store it for later comparison
        $iLastNum = $num1
    Endif
EndFunc

Func InsertText($text)
    GUICtrlSetData($Edit1, @CRLF & $text, 1)
EndFunc

Func Turnoff()
   Exit
EndFunc

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

Thank you sir

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