Mit Hilfe des Skriptes TextMeter von Bugfix und auf Grund dieses Posts, habe ich ein Skript geschrieben, welches einfach mehrfärbige Labels erzeugt.
Viel Spaß damit!
Spoiler anzeigen
#include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]GUICreate('Bunte Labels by funkey', 500, 200)
[/autoit] [autoit][/autoit] [autoit]_GuiCtrlCreateColoredLabel('Hallo[0x0000FF] Autoit.de![0x00FF00] Wie gefällt euch das?[0xFF0000]', 20, 20, 'Arial', 20)
_GuiCtrlCreateColoredLabel('D[0xFF00FF]a[0x0000FF]s[0x00FFFF] ist[0x00FF00] e[0xFFFF00]in[0xFFFFFF] ers[0x000000]ter Farb[0xFF0000]test[0x0000FF]', 20, 80, 'Times New Roman', 15)
GUISetState()
[/autoit] [autoit][/autoit] [autoit]_GuiCtrlCreateColoredLabel('A[0x0000FF]n[0xFF0000]i[0x0000FF]m[0xFF0000]a[0x0000FF]t[0xFF0000]i[0x0000FF]o[0xFF0000]n[0x0000FF] :)[0x00FFFF]', 40, 130, 'Microsoft Sans Serif', 45, 6, 300)
[/autoit] [autoit][/autoit] [autoit]Do
Sleep(10)
Until GUIGetMsg() = -3
Func _GuiCtrlCreateColoredLabel($sText, $iPosX, $iPosY, $sFont = 'Microsoft Sans Serif', $iFontSize = 8.5, $iFontAttributes = 0, $iSleep = 0)
;Author: funkey
Local $aTextPart = StringRegExp($sText, '.+?]', 3)
Local $aText, $hLabel[UBound($aTextPart)], $aSize[2] = [0, 0], $iWidthOld
For $i = 0 To UBound($aTextPart) - 1
$aText = StringSplit(StringTrimRight($aTextPart[$i], 1), '[', 2)
$iWidthOld += $aSize[0] - $iFontSize / 2
$aSize = _GetTextSize($aText[0], $sFont, $iFontSize, $iFontAttributes)
$hLabel[$i] = GUICtrlCreateLabel($aText[0], $iPosX + $iWidthOld, $iPosY, $aSize[0], $aSize[1])
GUICtrlSetColor(-1, $aText[1])
GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT
GUICtrlSetFont(-1, $iFontSize, 400, $iFontAttributes, $sFont)
Sleep($iSleep)
Next
Return $hLabel
EndFunc ;==>_GuiCtrlCreateColoredLabel
Func _GetTextSize($nText, $sFont = 'Microsoft Sans Serif', $iFontSize = 8.5, $iFontAttributes = 0)
;Author: Bugfix
;Modified: funkey
If $nText = '' Then Return
Local $hGui = GUICreate("Textmeter by Bugfix")
_GDIPlus_Startup()
Local $hFormat = _GDIPlus_StringFormatCreate(0)
Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, $iFontAttributes, 3)
Local $tLayout = _GDIPlus_RectFCreate(15, 171, 0, 0)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat)
Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width"))
Local $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height"))
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
GUIDelete($hGui)
Local $aSize[2] = [$iWidth, $iHeight]
Return $aSize
EndFunc ;==>_GetTextSize
Edit: Beispiel-Schriftart geändert