Jump to content

Recommended Posts

Posted

Hello, this is my code. Im trying make somethink like converter from autoit to html/bbcode

But it's really hard for me, maybe someone knows where i can find topic with this tool/script?

Sorry for bad english, and thx for any replies

Global $avgcol

Opt("GUICloseOnESC", 0) ; bez esc
;~ #include <shapedcontrols_udf.au3>
;~ #include <image_get_info.au3>


#include <GUIConstantsEx.au3>
#include <WinDowsConstants.au3>
#include <GuiListView.au3>
#include <Constants.au3>
#include <FontConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <GuiToolTip.au3>

#include <UpDownConstants.au3>
#include <GuiImageList.au3>
#include <ButtonConstants.au3>
#include <ScrollBarConstants.au3>
;~ #include <GUIScrollBars.au3>
;~ #include "MouseOnEvent.au3"


#include <ProgressConstants.au3>
#include <String.au3>


;~ #include <sqlite.au3>;Stop the Obfuscation process below this line
;~ #include <sqlite.dll.au3>

#include <GuiMenu.au3>
#include <GuiEdit.au3>
#include <GuiRichEdit.au3>

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <ListViewConstants.au3>
;~ #include <File.au3>
;~ #include <Array.au3>

;~ #include <GUIScrollbars_Ex.au3>
;~ #include <hover.au3>


Global $it = False
Global $un = False
Global $bo = False
Global $fo = False
Global $ro = False

Global $it2 = True
Global $un2 = True
Global $bo2 = True
Global $fo2 = True
Global $ro2 = True

;~ If _Singleton(@ScriptName, 1) = 0 Then
;~  MsgBox(0, "Błąd :(", "Program jest już uruchomiony")
;~  Exit
;~ EndIf

;~ OnAutoItExitRegister("usunall")


$gui = GUICreate("", 800, 600)



Global $pierwszy = _GUICtrlRichEdit_Create($gui, "", 10, 10, 300, 220, _
        BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
;~     _GUICtrlRichEdit_AppendText($pierwszy, @CR & "This is more text")

Global $drugi = _GUICtrlRichEdit_Create($gui, "", 320, 10, 300, 220, _
        BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
Global $przy = GUICtrlCreateButton('button', 35, 350, 100)


GUISetState(@SW_SHOW, HWnd($gui))


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $przy
            przek()
    EndSwitch
WEnd

Func przek()
    Local $polepierwsze = GUICtrlRead($pierwszy)


    Local $dl = _GUICtrlRichEdit_GetTextLength($pierwszy, True, True)

    For $i = 0 To $dl

        If $i = $dl Then ExitLoop

        Local $zazn = _GUICtrlRichEdit_SetSel($pierwszy, $i, $i + 1)
        Local $txt = _GUICtrlRichEdit_GetSelText($pierwszy)

        Local $rozm = _GUICtrlRichEdit_GetFont($pierwszy)
;~      ConsoleWrite($rozm[0]&@CRLF)
        If @error = -1 Then
;~          ConsoleWrite('wrong' & $i & @CRLF)
            ContinueLoop
        EndIf
        Local $atryb = _GUICtrlRichEdit_GetCharAttributes($pierwszy)

        Local $col = _GUICtrlRichEdit_GetCharColor($pierwszy)

        Local $cr = Hex($col, 6)

        Local $fontc = '0x' & StringMid($cr, 5, 2) & StringMid($cr, 3, 2) & StringMid($cr, 1, 2)
;~      If $atryb = '' Then

;~          $it = False
;~          $un = False
;~          $bo = False
;~          zrob()
;~          ContinueLoop
;~      EndIf
        If StringInStr($fontc, '0x000000') = 0 Then
            $fo = True
        Else
            $fo = False
        EndIf

        $rozm = String($rozm[0])

        If StringInStr($rozm, '10') = 0 Then
            $ro = True
        Else
            $ro = False
        EndIf


        If StringInStr($atryb, 'it+') <> 0 Then
            $it = True
        Else
            $it = False
        EndIf
        If StringInStr($atryb, 'un+') <> 0 Then
            $un = True
        Else
            $un = False
        EndIf
        If StringInStr($atryb, 'bo+') <> 0 Then
            $bo = True
        Else
            $bo = False
        EndIf
        zrob($fontc, $rozm)
        _GUICtrlRichEdit_AppendText($drugi, $txt)


    Next
EndFunc   ;==>przek


Func zrob($col, $rozmiar)



    If $ro Then
        If $ro2 Then
            _GUICtrlRichEdit_AppendText($drugi, '<font size =' & $rozmiar & '>')
            $ro2 = False
        EndIf
    Else
        If $ro2 = False Then
            _GUICtrlRichEdit_AppendText($drugi, '</font>')
            $ro2 = True
        EndIf
    EndIf



    If $fo Then
        If $fo2 Then
            _GUICtrlRichEdit_AppendText($drugi, '<font color =' & $col & '>')
            $fo2 = False
        EndIf
    Else
        If $fo2 = False Then
            _GUICtrlRichEdit_AppendText($drugi, '</font>')
            $fo2 = True
        EndIf
    EndIf





    If $it Then
        If $it2 Then
            _GUICtrlRichEdit_AppendText($drugi, '<i>')
            $it2 = False
        EndIf
    Else
        If $it2 = False Then
            _GUICtrlRichEdit_AppendText($drugi, '</i>')
            $it2 = True
        EndIf
    EndIf



    If $un Then
        If $un2 Then
            _GUICtrlRichEdit_AppendText($drugi, '<u>')
            $un2 = False
        EndIf
    Else
        If $un2 = False Then
            _GUICtrlRichEdit_AppendText($drugi, '</u>')
            $un2 = True
        EndIf
    EndIf




    If $bo Then
        If $bo2 Then
            _GUICtrlRichEdit_AppendText($drugi, '<b>')
            $bo2 = False
        EndIf
    Else
        If $bo2 = False Then
            _GUICtrlRichEdit_AppendText($drugi, '</b>')
            $bo2 = True
        EndIf
    EndIf



EndFunc   ;==>zrob
Posted (edited)

Hmm thx but i dont need Code Highlighter.

I need converter, somethink like this:

from _GUICtrlRichEdit_ where i have:

xxxxx asdasd nnnnb pofof pdsssso oppoop ops oofop fbmo sdfp

sd

ds

dsfsdgdfg fdg fd gfd df.gdf .fdgdfgfd

i want have in next _GUICtrlRichEdit_ this:

xxx<font size = 4>xx asdasd<font color = #FF0000> nnnnb</color></font> pofo<font size = 6>f pdss</font><font color = #FF8C00>sso oppoop ops oofop</color> fbmo sdfp
<u>sd</u>
<b>ds</b>
dsfs<i>dgdfg fdg fd gfd df.gdf .fd</i>gdfgfd

it's on forum? can someone help? please

Zwinny

Edited by ZwinnyRolnik

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...