SplashImage / -Text, randlos, formatierbar

    • Offizieller Beitrag

    Hi,
    ich habe hier mal SplashImage und SplashText in einer Funktion vereint.
    Die Anzeige erfolgt randlos. Beim Text kann Textfarbe, Hintergrundfarbe (oder Transparenz), Schrifthöhe und Font gesetzt werden.
    Die richtige Höhe für die Anzeige müßt ihr ggf. austesten.
    Für Image können wie im Original nur gif, jpg, bmp verwendet werden.

    Edit:
    - Bei Anzeige von Bildern braucht die Bildgröße nicht mehr übergeben werden, dies wird in der Funktion selbst ermittelt.
    - Fehlerbehandlung hinzugefügt.

    Edit2:
    - Benötigter Platz für Text wird selbst berechnet, keine Größenangabe mehr erforderlich. (Breite u. Höhe entfallen als Param)
    - Position ist per Standard rechts unterhalb der Maus

    Spoiler anzeigen
    [autoit]

    #include-once
    #include <StructureConstants.au3>
    #include <GDIPlus.au3>
    #include <WindowsConstants.au3>
    #include <WinAPI.au3>
    #include <FontConstants.au3>

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

    _SplashOn('Hello World Bla Bla Blub' & @crlf & 'Zeile 2', True, -1, -1, -1, -1, 0xFFFC91, 0, 16)
    Sleep(300)
    _SplashOn(@Systemdir & "\oobe\images\mslogo.jpg")
    Sleep(300)
    _SplashOn(@Systemdir & "\oobe\images\oemlogo.gif")
    Sleep(300)
    _SplashOn(@Systemdir & "\setup.bmp", False)
    Sleep(300)
    For $i = 60 To 30 Step -3
    _SplashOn("Hello world!", True, -1, -1, 300, 0x0000FF, -1, 1, $i, 'Comic Sans MS')
    Next
    For $i = 30 To 60 Step 3
    _SplashOn("Hello world!", True, -1, -1, 300, 0x0000FF, -1, 1, $i, 'Comic Sans MS')
    Next

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

    ;==================================================================================================
    ; Function Name: _SplashOn($Item, $fMouse=True, $left=-1, $top=-1, $timeout=-1, _
    ; $txtCol=-1, $bkCol=-1, $trans=1, $size=-1, $font=-1, $weight=400)
    ; Description:: Show an SplashImage (gif,jpg,bmp) or an SplashText
    ; Parameter(s): $Item - Path picture file or SplashText; Autodetection if file or text
    ; optional $fMouse - True (default) use mousepos for $left and $top
    ; optional $left - left margin (default=-1 horizontal centered)
    ; optional $top - upper margin (default=-1 vertikal centered)
    ; optional $timeout- time how long to show picture/text in ms (default=-1, 3000 ms)
    ; optional $txtCol - SplashText: text color RGB (default=-1, red)
    ; optional $bkCol - SplashText: back color RGB (default=-1, black)
    ; optional $trans - SplashText: background transparency yes/now (default=1, yes)
    ; optional $size - SplashText: font size (default=-1, 30) ; 14 conforms approximately 12 at TimesNewRoman
    ; optional $font - SplashText: font name (default=-1, Arial)
    ; optional $weight - normal (400) = -1 (Standard), bold (600)
    ; Return: Success - 1
    ; Failure - 0 set @error: 1= given file doesn't exist; 2= no size given for textarea
    ; Author(s): BugFix ([email='bugfix@autoit.de'][/email])
    ;==================================================================================================
    Func _SplashOn($Item, $fMouse=True, $left=-1, $top=-1, $timeout=-1, _
    $txtCol=-1, $bkCol=-1, $trans=1, $size=-1, $font=-1, $weight=400)
    Local $width, $height
    If $fMouse Then
    Local $MPos = MouseGetPos()
    $left = $MPos[0]
    $top = $MPos[1]
    EndIf
    If $timeout < 0 Then $timeout = 3000
    If $txtCol < 0 Then $txtCol = 0xFF0000
    If $bkCol < 0 Then $bkCol = 0x000000
    If $trans < 0 Then $trans = 0
    If $size < 0 Then $size = 30
    If $font = -1 Then $font = 'Arial'
    If StringRegExp(StringLeft($Item, 3), '[a-zA-Z]:\\') Then ; picture
    If Not FileExists($Item) Then Return SetError(1,0,0)
    ;~ If ($width = -1) Or ($height = -1) Then
    Local $objShell = ObjCreate("Shell.Application")
    Local $objFSO = ObjCreate("Scripting.FileSystemObject")
    Local $objFile = $objFSO.GetFile($Item)
    Local $FileName = $objFSO.GetFileName($objFile)
    Local $objFolder = $objShell.Namespace($objFSO.GetParentFolderName($objFile))
    For $strFileName In $objFolder.Items
    If $objFolder.GetDetailsOf($strFileName, 0) <> $FileName Then ContinueLoop
    $width = StringRegExpReplace($objFolder.GetDetailsOf($strFileName, 27), '(\d+).*', '$1')
    $height = StringRegExpReplace($objFolder.GetDetailsOf($strFileName, 28), '(\d+).*', '$1')
    Next
    ;~ EndIf
    Local $gui = GUICreate("", $width, $height, $left, $top, $WS_POPUP, $WS_EX_TOPMOST)
    Local $ctrl = GUICtrlCreatePic($Item, 0, 0, $width, $height)
    GUISetState(@SW_SHOW)
    Local $pos = WinGetPos($gui), $combined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)
    Local $ctrl_pos = ControlGetPos($gui, "", $ctrl)
    Local $ctrl_rgn = _WinAPI_CreateRectRgn($ctrl_pos[0], $ctrl_pos[1], $ctrl_pos[0] + $ctrl_pos[2], $ctrl_pos[1] + $ctrl_pos[3])
    _WinAPI_CombineRgn($combined_rgn, $combined_rgn, $ctrl_rgn, $RGN_OR)
    _WinAPI_DeleteObject($ctrl_rgn)
    _WinAPI_SetWindowRgn($gui, $combined_rgn)
    Sleep($timeout)
    GUIDelete($gui)
    Else ; text
    Local $gui = GUICreate('')
    _GDIPlus_Startup()
    Local $hFormat = _GDIPlus_StringFormatCreate(0)
    Local $hFamily = _GDIPlus_FontFamilyCreate($font)
    Local $style = 0
    If $weight > 400 Then $style = 1
    Local $hFont = _GDIPlus_FontCreate($hFamily, $size, $style, 3)
    Local $tLayout = _GDIPlus_RectFCreate(15, 171, 0, 0)
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($gui)
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $Item, $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($gui)
    $width = $iWidth
    $height = $iHeight
    If $left = -1 Then $left = Int((@DesktopWidth/2) - ($width/2))
    If $top = -1 Then $top = Int((@DesktopHeight/2) - ($height/2))
    Local $tRECT, $hFont, $hOldFont, $hDC
    If $left + $width > @DesktopWidth Then $left -= $width
    If $top + $height > @DesktopHeight Then $top -= $height
    $tRECT = DllStructCreate($tagRect)
    DllStructSetData($tRECT, "Left", $left)
    DllStructSetData($tRECT, "Top", $top)
    DllStructSetData($tRECT, "Right", $left + $width)
    DllStructSetData($tRECT, "Bottom", $top + $height)
    $hDC = _WinAPI_GetDC(0)
    $hFont = _WinAPI_CreateFont($size, 0, 0, 0, $weight, False, False, False, $DEFAULT_CHARSET, _
    $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, $font)
    $hOldFont = _WinAPI_SelectObject($hDC, $hFont)
    Local $sH = Hex($txtCol,6)
    $txtCol = '0x' & StringRight($sH, 2) & StringMid($sH,3,2) & StringLeft($sH, 2)
    $sH = Hex($BkCol,6)
    $bkCol = '0x' & StringRight($sH, 2) & StringMid($sH,3,2) & StringLeft($sH, 2)
    _WinAPI_SetTextColor($hDC, $txtCol)
    _WinAPI_SetBkColor($hDC, $bkCol)
    If $trans Then _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    Local $timer = TimerInit()
    Do
    _WinAPI_DrawText($hDC, $Item, $tRECT, $DT_CENTER)
    Sleep(20)
    Until TimerDiff($timer) > $timeout
    _WinAPI_SelectObject($hDC, $hOldFont)
    _WinAPI_DeleteObject($hFont)
    _WinAPI_ReleaseDC(0, $hDC)
    _WinAPI_InvalidateRect(0, 0)
    $tRECT = 0
    EndIf
    Return 1
    EndFunc ;==>_SplashOn

    [/autoit]
  • colle sache nur funktioniert entweder dein bsp nicht oder es ist irgendwo ein Fehler, denn bei mir fängt das ding an wie blöd zu blinken. eine zweite zeile blinkt nur ganz kurz auf.
    sobal das tooltip 2 angezeig wird hab ich im hiintergrund dessen noch das erste tooltip

    Das finden von Rechtschreibfehlern muss sofort und unverzüglich dem Autor gemeldet werden. Das eigennützige Verwenden dieser Rechtschreibfehler ist strengstens untersagt und kann mit Freiheitsenzug bestraft werden.

  • er hatt aber schon bei dem einfachen splash on

    [autoit]

    _SplashOn('Hello World Bla Bla Blub' & @crlf & 'Zeile 2', True, -1, -1, -1, -1, 0xFFFC91, 0, 16)

    [/autoit]


    so einse probleme die zweite zweile wird nicht dargestellt

    Das finden von Rechtschreibfehlern muss sofort und unverzüglich dem Autor gemeldet werden. Das eigennützige Verwenden dieser Rechtschreibfehler ist strengstens untersagt und kann mit Freiheitsenzug bestraft werden.

  • nein eine Fehlermeldung bekomme ich nicht. bei dem Beispiel

    [autoit]

    _SplashOn('Hello World Bla Bla Blub' & @crlf & 'Zeile 2', True, -1, -1, -1, -1, 0xFFFC91, 0, 16)

    [/autoit]


    wird einfach die zweite Zeile nicht angezeigt

    Das finden von Rechtschreibfehlern muss sofort und unverzüglich dem Autor gemeldet werden. Das eigennützige Verwenden dieser Rechtschreibfehler ist strengstens untersagt und kann mit Freiheitsenzug bestraft werden.