Jump to content

[Solved]Edit replace last line OR Remove it....How?


Recommended Posts

How I could replace edit last line? I know how I can find last line, but I dont know how to remove it.I don't want guictrlsetdata, cuz it processes whole edit, but if I have data in amount 200 kb in edit, and I need to update Edit 1 often, 2-3 times in one sec, then guictrlsetdata makes cpu usage raise.But _GUICtrlEdit_AppendText can do it with less cpu usage i think but if I want to use _GUICtrlEdit_AppendText I need to remove lastline before _GUICtrlEdit_AppendText writes it again.

Edit:

Solution:

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 616, 365, 193, 125)
$Edit1 = GUICtrlCreateEdit("", 96, 48, 425, 273)
GUICtrlSetData(-1, "")
GUISetState(@SW_SHOW)
InetGet("http://mirrors.kahuki.com/apache/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi", "test.msi", 1, 1)
$z = InetGetSize("http://mirrors.kahuki.com/apache/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi")
$sText = GUICtrlRead ($Edit1)
While @InetGetActive
_GUICtrlEdit_SetText($Edit1,$sText & @crlf & "Downloading file: http://mirrors.kahuki.com/apache/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi, " & @CRLF & @InetGetBytesRead&" Bytes downladed of" &$z )
  Sleep(50)
Wend
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Edited by E1M1

edited

Link to comment
Share on other sites

Here is simple version of my script, now you see why i need to replace last line. I want to have only 1 line of text Downloaded " & @InetGetBytesRead & " bytes"&@CRLF instead of hundreds and thousands lines of text.

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 616, 365, 193, 125)
$Edit1 = GUICtrlCreateEdit("", 96, 48, 425, 273)
GUICtrlSetData(-1, "Downloading:http://mirrors.kahuki.com/apache/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi")
GUISetState(@SW_SHOW)
InetGet("http://mirrors.kahuki.com/apache/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi", "test.msi", 1, 1)

While @InetGetActive
  _GUICtrlEdit_AppendText($Edit1,"Downloaded " & @InetGetBytesRead & " bytes"&@CRLF)
  Sleep(100)
Wend
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Edited by E1M1

edited

Link to comment
Share on other sites

Here is simple version of my script, now you see why i need to replace last line. I want to have only 1 line of text Downloaded " & @InetGetBytesRead & " bytes"&@CRLF instead of hundreds and thousands lines of text.

#include <EditConstants.au3>
 #include <GUIConstantsEx.au3>
 #include <WindowsConstants.au3>
 #Include <GuiEdit.au3>
 
 #Region ### START Koda GUI section ### Form=
 $Form1 = GUICreate("Form1", 616, 365, 193, 125)
 $Edit1 = GUICtrlCreateEdit("", 96, 48, 425, 273)
 GUICtrlSetData(-1, "Downloading:http://mirrors.kahuki.com/apache/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi")
 GUISetState(@SW_SHOW)
 InetGet("http://mirrors.kahuki.com/apache/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi", "test.msi", 1, 1)
 
 While @InetGetActive
   _GUICtrlEdit_AppendText($Edit1,"Downloaded " & @InetGetBytesRead & " bytes"&@CRLF)
   Sleep(100)
 Wend
 #EndRegion ### END Koda GUI section ###
 
 While 1
     $nMsg = GUIGetMsg()
     Switch $nMsg
         Case $GUI_EVENT_CLOSE
             Exit
 
     EndSwitch
 WEnd
Maybe this would work

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 616, 365, 193, 125)
$Edit1 = GUICtrlCreateEdit("", 96, 48, 425, 273)
GUICtrlSetData(-1, "Downloading:http://mirrors.kahuki.com/apache/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi")
GUISetState(@SW_SHOW)
InetGet("http://mirrors.kahuki.com/apache/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi", "test.msi", 1, 1)


;get the current length of the text in the edit
$iLength1 = _GUICtrlEdit_GetTextLen($Edit1)
While @InetGetActive
    _GUICtrlEdit_SetSel($Edit1,$iLength1, _GUICtrlEdit_GetTextLen($Edit1))
    _GUICtrlEdit_ReplaceSel($Edit1,"Downloaded " & @InetGetBytesRead & " bytes"&@CRLF)
; _GUICtrlEdit_AppendText($Edit1,"Downloaded " & @InetGetBytesRead & " bytes"&@CRLF)
  Sleep(100)
Wend
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...