Wenn die Größe des Fensters an den Text angepasst werden soll, sollte man auch die Größe berechnen:
AutoIt
#include <GDIPlus.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPISysInternals.au3>
Global $sFile = "C:\Users\Administrator\Downloads\Aufgaben\Datei"
Global $sFontname = 'Arial', $sFontSize = 16
Global $sText = StringFormat('"%s" wurde geschrieben.', $sFile)
Global $tRect = _CalcTextSize($sText, $sFontname, $sFontSize)
SplashTextOn('Bitte warten', $sText, Ceiling($tRect.Width), Ceiling($tRect.Height) + 24, -1, -1, 20, $sFontname, $sFontSize)
sleep(5000)
Func _CalcTextSize(ByRef $sText, ByRef $sFontname, $iFontSize)
Local $hDC, $hGraphic, $hFormat, $hFamily, $tLayout, $hFont, $aInfo
_GDIPlus_Startup()
$hDC = _WinAPI_GetWindowDC(0)
$hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC)
$hFormat = _GDIPlus_StringFormatCreate(0x1000) ; 0x1000 = wrapping to the next line is disabled
$hFamily = _GDIPlus_FontFamilyCreate($sFontname)
$tLayout = _GDIPlus_RectFCreate(0, 0, @DesktopWidth, @DesktopHeight)
$hFont = _GDIPlus_FontCreate($hFamily, $iFontSize)
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sText, $hFont, $tLayout, $hFormat)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_ReleaseDC(0, $hDC)
_GDIPlus_Shutdown()
Return $aInfo[0]
EndFunc
Alles anzeigen