Probleme mit GuiRichEdit Udpate (@Progandy???)

  • Hallo zusammen,

    ich habe mir ein Tool zum mitlesen einer DosBox programmiert.
    Die Ausgaben werden dabei geparst und abhängig vom Inhalt unterschiedlich eingefärbt.

    Mein Problem ist nun, dass ich wohl eine alte Version der GuiRichtEdit.au3 benutzt habe. Nach dem Update von AutoIt auf 3.3.6.x sind die GuiCtrlRich-Aufrufe nicht mehr kompatibel.

    Das meiste konnte ich anpassen. Bekomme es aber nicht hin, dass nur bestimmte Textteile eingefärbt/fett dargestellt werden.

    Mit _GuiCtrlRichEdit_SetCharColor($REdit,0xFF0000) ändert sich die gesamte Farbe im Editfenster und nicht nur die des nächsten eingefügten Textes.
    Gleich gilt für _GUICtrlRichEdit_SetCharAttributes($REdit,"+bo",0)

    Kann mir evtl. jemand bei der Umsetzung helfen?

    Cu
    Superelmo


    Hier nun mal der alte Code:

    [autoit][/autoit][autoit][/autoit][autoit]

    ; includes
    #include <GUIConstants.au3>
    #include "constants.au3"
    #include <WindowsConstants.au3>
    #include <EditConstants.au3>
    #include <StaticConstants.au3>
    #include "GuiRichEdit.au3"

    [/autoit][autoit][/autoit][autoit]

    Opt('MustDeclareVars', 1)

    [/autoit][autoit][/autoit][autoit]

    ; local variables
    Local $gui, $oRP, $REdit
    Local $file, $i
    Local $line, $Type, $Msg

    [/autoit][autoit][/autoit][autoit]

    ; const definitions
    Global Const $MSG_WARNING = 2
    Global Const $MSG_ERROR = 1
    Global Const $MSG_NORMAL = 0

    [/autoit][autoit][/autoit][autoit]

    Global Const $RAM_WITHLOG = 0
    Global Const $RAM_WITHOUTLOG = 1

    [/autoit][autoit][/autoit][autoit]

    ;ReadAlongMake($RAM_WITHOUTLOG)

    [/autoit][autoit][/autoit][autoit]

    ;===============================================================================
    ;
    ; Description: ReadAlongMake
    ; Create GUI and execute the Make-Batch.
    ; The write out the messages from Make-Process include parsing and LogFile
    ;
    ; Parameter(s): $sMessage - text which should be output in the TextElement
    ;
    ; Requirement:
    ; Return Value(s): none
    ;
    ; Note(s):
    ;===============================================================================
    Func ReadAlongMake($LogParam)
    ;create GUI
    $gui = GUICreate("MakeLog",1220,820)
    $oRP = ObjCreate("RICHTEXT.RichtextCtrl.1")

    [/autoit][autoit][/autoit][autoit]

    $REdit = _GUICtrlRichEdit_Create($gui, 10, 10, 1200, 800,BitOR($ES_WANTRETURN, $ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    _GUICtrlRichEdit_BkColor($REdit,0xf9f4f0)
    _GUICtrlRichEdit_SetOLECallback($REdit)
    _GUICtrlRichEdit_SetFontName($REdit, "Courier New",0)
    _GUICtrlRichEdit_SetFontSize($REdit, 9,0)
    _GUICtrlRichEdit_SetBold($REdit,0,0)

    [/autoit][autoit][/autoit][autoit]

    GUISetState()

    [/autoit][autoit][/autoit][autoit]

    ; Create LogFile
    CreateLog($LogParam)

    [/autoit][autoit][/autoit][autoit]

    ; execute Make
    $i=Run(@ComSpec &" /c makeit ", @ScriptDir, @SW_HIDE, $STDOUT_CHILD+$STDERR_CHILD)

    [/autoit][autoit][/autoit][autoit]

    ; readout the information from make process
    While 1
    $line = StdoutRead($i)
    If @error Then ExitLoop
    if StringCompare($line, "") <>0 Then
    WriteLineToLog($LogParam, $line)
    MemoWrite($line)
    endif

    [/autoit][autoit][/autoit][autoit]

    $line = StderrRead($i)
    if StringCompare($line, "") <>0 Then
    WriteLineToLog($LogParam, $line)
    MemoWrite($line)
    endif

    [/autoit][autoit][/autoit][autoit]

    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then Exit
    Wend

    [/autoit][autoit][/autoit][autoit]

    While 1
    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then Exit
    WEnd
    EndFunc

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    ;===============================================================================
    ;
    ; Description: MemoWrite
    ; The transferd text is parse to the words 'warning' and 'error'.
    ; Is one of this found then the text gets a special format
    ;
    ; Parameter(s): $sMessage - text which should be output in the TextElement
    ;
    ; Requirement:
    ; Return Value(s): none
    ;
    ; Note(s):
    ;===============================================================================
    Func MemoWrite($sMessage)

    [/autoit][autoit][/autoit][autoit]

    ; set default to MSG_NORMAL
    $Type = $MSG_NORMAL

    [/autoit][autoit][/autoit][autoit]

    if StringInStr($sMessage,"warning") <> 0 Then
    $Type = $MSG_WARNING
    ElseIf StringInStr($line,"error") <>0 Then
    $Type = $MSG_ERROR
    EndIf

    [/autoit][autoit][/autoit][autoit]

    Switch $Type
    case $MSG_WARNING
    ; write blue and Bold
    _GUICtrlRichEdit_SetFontColor($REdit,0xFF0000)
    _GUICtrlRichEdit_SetBold($REdit,1)
    case $MSG_ERROR
    ; write red and Bold
    _GUICtrlRichEdit_SetFontColor($REdit,0x0000FF)
    _GUICtrlRichEdit_SetBold($REdit,1)
    case Else
    _GUICtrlRichEdit_SetFontColor($REdit,0x000000)
    _GUICtrlRichEdit_SetBold($REdit,0)
    EndSwitch

    [/autoit][autoit][/autoit][autoit]

    _GUICtrlRichEdit_SetFontSize($REdit, 9,0)
    _GUICtrlRichEdit_AppendText($REdit,$sMessage)
    EndFunc ;==> MemoWrite

    [/autoit][autoit][/autoit][autoit]

    ;===============================================================================
    ;
    ; Description: WriteLineToLog($data)
    ; The transferd text write to the LogFile.
    ; The file is reopen/close every time to have the opportunity that the file can be read/open meanwhile MakeProcess
    ;
    ; Parameter(s): $data - text which should be output in the LogFile
    ;
    ; Requirement:
    ; Return Value(s): none
    ;
    ; Note(s):
    ;===============================================================================
    Func WriteLineToLog($LogParam, $data)
    if $LogParam = $RAM_WITHOUTLOG then return
    $file = FileOpen("c:\temp\Make.log", 9)
    FileWriteLine($file, $data)
    FileClose($file)
    EndFunc ;==> WriteLineToLog

    [/autoit][autoit][/autoit][autoit]

    ;===============================================================================
    ;
    ; Description: CreateLog()
    ; Creates the LogFile.
    ;
    ; Parameter(s):
    ;
    ; Requirement:
    ; Return Value(s):
    ;
    ; Note(s):
    ;===============================================================================
    Func CreateLog($LogParam)
    if $LogParam = $RAM_WITHOUTLOG then return
    $file = FileOpen("c:\temp\Make.log", 10)
    FileClose($file)
    EndFunc ;==> CreateLog

    [/autoit]


    Und hier mal der Code mit den Umstellung soweit wie ich gekommen war.

    [autoit]


    ; includes
    #include <GUIConstants.au3>
    #include "constants.au3"
    #include <WindowsConstants.au3>
    #include <EditConstants.au3>
    #include <StaticConstants.au3>
    #include <GuiRichEdit.au3>

    [/autoit][autoit][/autoit][autoit]

    Opt('MustDeclareVars', 1)

    [/autoit][autoit][/autoit][autoit]

    ; local variables
    Local $gui, $oRP, $REdit
    Local $file, $i
    Local $line, $Type, $Msg

    [/autoit][autoit][/autoit][autoit]

    ; const definitions
    Global Const $MSG_WARNING = 2
    Global Const $MSG_ERROR = 1
    Global Const $MSG_NORMAL = 0

    [/autoit][autoit][/autoit][autoit]

    Global Const $RAM_WITHLOG = 0
    Global Const $RAM_WITHOUTLOG = 1

    [/autoit][autoit][/autoit][autoit]

    ReadAlongMake($RAM_WITHOUTLOG)

    [/autoit][autoit][/autoit][autoit]

    ;===============================================================================
    ;
    ; Description: ReadAlongMake
    ; Create GUI and execute the Make-Batch.
    ; The write out the messages from Make-Process include parsing and LogFile
    ;
    ; Parameter(s): $sMessage - text which should be output in the TextElement
    ;
    ; Requirement:
    ; Return Value(s): none
    ;
    ; Note(s):
    ;===============================================================================
    Func ReadAlongMake($LogParam)
    ;create GUI
    $gui = GUICreate("MakeLog",1220,820)
    ;$oRP = ObjCreate("RICHTEXT.RichtextCtrl.1")

    [/autoit][autoit][/autoit][autoit]

    $REdit = _GUICtrlRichEdit_Create($gui, "", 10, 10, 1200, 800,BitOR($ES_WANTRETURN, $ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    _GUICtrlRichEdit_SetBkColor($REdit,0xf9f4f0)
    ;~ ;_GUICtrlRichEdit_SetOLECallback($REdit)
    ;~ ;_GUICtrlRichEdit_SetFontName($REdit, "Courier New",0)
    _GUICtrlRichEdit_SetFont($REdit, 10, "Courier New")
    ;~ ;_GUICtrlRichEdit_SetFontSize($REdit, 9,0)
    _GUICtrlRichEdit_SetCharAttributes($REdit,"-bo",0)

    [/autoit][autoit][/autoit][autoit]

    GUISetState()

    [/autoit][autoit][/autoit][autoit]

    _GuiCtrlRichEdit_SetText($REdit, "Started..........")

    [/autoit][autoit][/autoit][autoit]

    ; Create LogFile
    CreateLog($LogParam)

    [/autoit][autoit][/autoit][autoit]

    ; execute Make
    $i=Run(@ComSpec &" /c makeit ", @ScriptDir, @SW_HIDE, $STDOUT_CHILD+$STDERR_CHILD)

    [/autoit][autoit][/autoit][autoit]

    ; readout the information from make process
    While 1
    $line = StdoutRead($i)
    If @error Then ExitLoop
    if StringCompare($line, "") <>0 Then
    WriteLineToLog($LogParam, $line)
    MemoWrite($line)
    endif

    [/autoit][autoit][/autoit][autoit]

    $line = StderrRead($i)
    if StringCompare($line, "") <>0 Then
    WriteLineToLog($LogParam, $line)
    MemoWrite($line)
    endif

    [/autoit][autoit][/autoit][autoit]

    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then Exit
    Wend

    [/autoit][autoit][/autoit][autoit]

    While 1
    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then Exit
    WEnd
    EndFunc

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    ;===============================================================================
    ;
    ; Description: MemoWrite
    ; The transferd text is parse to the words 'warning' and 'error'.
    ; Is one of this found then the text gets a special format
    ;
    ; Parameter(s): $sMessage - text which should be output in the TextElement
    ;
    ; Requirement:
    ; Return Value(s): none
    ;
    ; Note(s):
    ;===============================================================================
    Func MemoWrite($sMessage)

    [/autoit][autoit][/autoit][autoit]

    ; set default to MSG_NORMAL
    $Type = $MSG_NORMAL

    [/autoit][autoit][/autoit][autoit]

    if StringInStr($sMessage,"warning") <> 0 Then
    $Type = $MSG_WARNING
    ElseIf StringInStr($line,"error") <>0 Then
    $Type = $MSG_ERROR
    EndIf

    [/autoit][autoit][/autoit][autoit]

    Switch $Type
    case $MSG_WARNING
    ; write blue and Bold
    _GuiCtrlRichEdit_SetCharColor($REdit,0xFF0000)
    _GUICtrlRichEdit_SetCharAttributes($REdit,"+bo",0)
    case $MSG_ERROR
    ; write red and Bold
    _GuiCtrlRichEdit_SetCharColor($REdit,0x0000FF)
    _GUICtrlRichEdit_SetCharAttributes($REdit,"+bo",0)
    case Else
    _GuiCtrlRichEdit_SetCharColor($REdit,0x000000)
    _GUICtrlRichEdit_SetCharAttributes($REdit,"-bo",1)
    EndSwitch

    [/autoit][autoit][/autoit][autoit]

    ;_GUICtrlRichEdit_SetFontSize($REdit, 9,0)
    _GUICtrlRichEdit_AppendText($REdit, $sMessage)

    [/autoit][autoit][/autoit][autoit]

    EndFunc ;==> MemoWrite

    [/autoit][autoit][/autoit][autoit]

    ;===============================================================================
    ;
    ; Description: WriteLineToLog($data)
    ; The transferd text write to the LogFile.
    ; The file is reopen/close every time to have the opportunity that the file can be read/open meanwhile MakeProcess
    ;
    ; Parameter(s): $data - text which should be output in the LogFile
    ;
    ; Requirement:
    ; Return Value(s): none
    ;
    ; Note(s):
    ;===============================================================================
    Func WriteLineToLog($LogParam, $data)
    if $LogParam = $RAM_WITHOUTLOG then return
    $file = FileOpen("c:\temp\Make.log", 9)
    FileWriteLine($file, $data)
    FileClose($file)
    EndFunc ;==> WriteLineToLog

    [/autoit][autoit][/autoit][autoit]

    ;===============================================================================
    ;
    ; Description: CreateLog()
    ; Creates the LogFile.
    ;
    ; Parameter(s):
    ;
    ; Requirement:
    ; Return Value(s):
    ;

    [/autoit][autoit][/autoit][autoit]

    ; Note(s):
    ;===============================================================================
    Func CreateLog($LogParam)
    if $LogParam = $RAM_WITHOUTLOG then return
    $file = FileOpen("c:\temp\Make.log", 10)
    FileClose($file)
    EndFunc ;==> CreateLog

    [/autoit]
  • Hmm, die RichEdit-UDF, die bei AutoIt dabei ist, verstehe ich nicht so ganz ^^
    Ich glaube, dass die Funktionen nicht so funktionieren wie sie dokumentiert sind.
    Auf jeden Fall erlaubt SetCharAttributes nur True und False als letzen Parameter und keine 0