i know, is too late, but my simplified version for this problem is:
;also remember includes
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <Date.au3>
#include <GuiEdit.au3>
func writeLog($message) ;Function for write in a edit
;write in the last position (append in last lline)
;
_GUICtrlEdit_AppendText($edit, String(_NowTime())&" - "&$msg&@CRLF)
If _GUICtrlEdit_GetLineCount($logBtMsg) > 101 Then ;se atingir este limite de linhas
$linha= _GUICtrlEdit_LineIndex($logBtMsg,51) ;pega a posição e o numero da linha DEIXA NO EDIT AS ULTIMAS 51 LINHAS
_GUICtrlEdit_SetSel($logBtMsg, 0, $linha) ;seleciona do inicio até o fim da linha selecionada
_GUICtrlEdit_ReplaceSel($logBtMsg, "", False) ;apaga
EndIf
EndFunc