Angel Posted August 15, 2006 Share Posted August 15, 2006 Hi guys, is there a simple (or even a complex ) way to append text to the end of an edit box, regardless of the caret position? I want to be able to do this without scrolling down to the bottom as I want to be able to append some text while the user is looking at the top of the edit box. I currently use the following code to append the text: GUICtrlSetData ($logCtrlId, $text & @CRLF, 1) Right now, if the user clicked somewhere on the Edit box, changing the caret position from the end to some other part in the middle of the text, the next time I append some text it is added where the caret position is. Instead I'd like to always append the text to the last line of the edit box. Is this possible? Thanks, Angel Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted August 15, 2006 Moderators Share Posted August 15, 2006 I would think this would work: GUICtrlSetData ($logCtrlId, GUICtrlRead ($logCtrlId) & $text & @CRLF, "") Link to comment Share on other sites More sharing options...
Angel Posted August 15, 2006 Author Share Posted August 15, 2006 I would think this would work: GUICtrlSetData ($logCtrlId, GUICtrlRead ($logCtrlId) & $text & @CRLF, "") That would just overwrite the contents of the control with the old contents plus the new string, right? The problem is that it seems that that would change the "position" (the scroll) so the user could not be reading the contents of the edit box while the script is updating it. Also, the edit box contains a huge amount of data, and is updated constantly, so I fear that the performance of the GUI would be pretty bad if I did that... The solution that I am looking for is to have some way of moving the caret to the end of the editbox and then appending the new data into the edit box as I was doing before. I know that you can change the caret position using one of the EditBox User functions, but I don't konw how to get the position of the last line in the edit box. Is there some way to do that? Angel Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 15, 2006 Moderators Share Posted August 15, 2006 (edited) I don't see you being able to do that without something like ControlSend()... and I've not tested that either.Edit:Looks like there's a function for everything but _GUICtrlEditAddLine Ohhhh Gary ... Edited August 15, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Angel Posted August 15, 2006 Author Share Posted August 15, 2006 I don't see you being able to do that without something like ControlSend()... and I've not tested that either.Edit:Looks like there's a function for everything but _GUICtrlEditAddLine Ohhhh Gary ... Where did you see that function? I can't find it in the "GuiEdit Management" section of the User Defined functions in the help file of the latest version (v3.2.0.1)!Angel Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 15, 2006 Moderators Share Posted August 15, 2006 Where did you see that function? I can't find it in the "GuiEdit Management" section of the User Defined functions in the help file of the latest version (v3.2.0.1)!AngelRe-Read what I typed... I typed, everything but... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Danny35d Posted August 16, 2006 Share Posted August 16, 2006 I know that you can change the caret position using one of the EditBox User functions, but I don't konw how to get the position of the last line in the edit box. Is there some way to do that?To get the last line you can used _GUICtrlEditLineCount($h_Edit) AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Angel Posted August 16, 2006 Author Share Posted August 16, 2006 Re-Read what I typed... I typed, everything but...Sorry, I did not understand you. As you can guess English is not my first language! I managed to do this by using _GUICtrlEditLineCount. I'll try to post the solution tomorrow (hopefully I'll remember!). But I did not manage to avoid the control from scrolling down It is true that it seems that a _GuiCtrolEditAddLine is missing!Thanks for the help!Angel Link to comment Share on other sites More sharing options...
therks Posted February 12, 2007 Share Posted February 12, 2007 Hate to revive a long dead thread (6 months, eep), but I'm having similar troubles with the very same thing, and was wondering if Angel (or anybody else for that matter) may have come up with something. I'm currently trying something along the lines of: $end = StringLen(GUICtrlRead($editCtrl)) _GUICtrlEditSetSel($editCtrl, $end, $end) GuiCtrlSetData($editCtrl, $line & @CRLF, 1)oÝ÷ Ùhbr(®Kw¡§^·!÷n®)à¶g«bú+«b¢x¬mè§ â¶×§¶ayçbµÊ'¶º%ʧ¢Ú'+kÊÚ©àzØ^qªÞ¶,ب»iËnjYrv¶ jwfjG±é^rبØ^+l¢gg¬Â)e¢÷«Â¸{Z·*.«Þ±é^r×"Ýý²÷«É©ç£(§©Ý#fÂëçm«mêÞßÛ'£²¶(®F«¢éݶ¬{¦Ûh¥êájÆëayçbµÊ'¶º%Âéߢ»n«^)^j÷¬¶®±êî¦åzÚ,rº%êZ×hÂv§v·v¦ëZ²+wöÆ©¥æ«xº-zØb²Èh®Û®*m¶^춶{Z´ý½æÞzxZ¾)঺é¬Â+ajëh×6#include <GUIConstants.au3> #include <GUIEdit.au3> GUICreate('', 400, 300) $buttonCtrl = GUICtrlCreateButton('Click', 0, 0, 40, 20) $editCtrl = GUICtrlCreateEdit('', 0, 20, 400, 280, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) GUISetState() While 1 $gm = GUIGetMsg() Switch $gm Case $buttonCtrl GuiCtrlSetData($editCtrl, '') For $i = 1 to 200 $end = StringLen(GUICtrlRead($editCtrl)) _GUICtrlEditSetSel($editCtrl, $end, $end) GuiCtrlSetData($editCtrl, 'Line ' & $i & @CRLF, 1) Sleep(10) Next Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd If you run that script, then click the "Click" button, and then try to click and drag in the edit control while it's writing, you'll see that it will overwrite some of the output. Gary really does need to make a GUICtrlEditAddLine. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
arcker Posted February 17, 2007 Share Posted February 17, 2007 from my project (work on normal edit too) ; ==================================================================================================== ; Description ..: Append some text to the control ; Parameters ...: $hWnd - Handle to the control ; $iText - Text to append ; $hLine - insert the @crlf at the end (default = True) ; Return values : Returns the index of the first new image if successful, or -1 otherwise ; Author .......: Yoan Roblet (Arcker) ; Notes ........: ; ==================================================================================================== Func _RichEdit_AddLine($hWnd, $iText, $hLine = True) Local $hTextLengh $hTextLengh = _API_SendMessage ($hWnd, $WM_GETTEXTLENGTH, 0, 0); _API_SendMessage ($hWnd, $EM_SETSEL, $hTextLengh, $hTextLengh); If $hLine Then _GUICtrlEditReplaceSel($hWnd, 1, $iText & @CRLF); Else _GUICtrlEditReplaceSel($hWnd, 1, $iText); EndIf EndFunc ;==>_RichEdit_AddLine -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now