Jump to content

ControlGetText How to use to get Last text in createEdit?


senatin
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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

"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

#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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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