Jump to content

Fade in label text


Lucid
 Share

Recommended Posts

I'm still new to AutoIt and have run into something I can't seem to figure out. It seems like it shouldn't be too hard to do, but I can't find anything on the web or these forums, and my own testing hasn't come up with anything usable.

What I'm trying to do is have some label text (within a GUI that I created) fade in, wait maybe 60 seconds, fade out, and a second message fade in, wait 60 seconds, and then fade out (repeating for a couple of other messages). Can anyone point me in the right direction, or share some code, to help get me rolling? Thanks!

Link to comment
Share on other sites

Search GUI animate and/or _WinAPI_AnimateWindow() then create a child GUI and animate that instead of a label.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Something like this here?

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Test", 468, 324, -1, -1, Default, BitOR($WS_EX_COMPOSITED, $WS_EX_LAYERED))
GUISetBkColor(0xFFFFFF, $hGUI)
$iButton = GUICtrlCreateButton("Button", 17, 23, 70, 67)
$iInput = GUICtrlCreateInput("Input", 109, 28, 338, 62)
$iRadio = GUICtrlCreateRadio("Radio", 17, 114, 78, 18)
$iRadio2 = GUICtrlCreateRadio("Radio", 17, 140, 55, 19)
$iCheckbox = GUICtrlCreateCheckbox("Checkbox", 109, 114, 83, 18)
$iProgress = GUICtrlCreateProgress(109, 140, 338, 29)
GUICtrlSetData(-1, 50)
$iLabel = GUICtrlCreateLabel("AutoIt rulez!", 17, 179, 430, 88)
GUICtrlSetStyle(-1, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 50, 400, 0, "Comic Sans MS", 4)
$iButton2 = GUICtrlCreateButton("Exit", 391, 284, 56, 29)
GUISetState()

AdlibRegister("LabelFader", 10)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $iButton2
            AdlibUnRegister("LabelFader")
            Exit
    EndSwitch
WEnd

Func LabelFader()
    Local Static $iColor = 0x00, $iDir = 2, $c = 1
    Local $aText[2] = ["AutoIt rulez!", "coded by UEZ"]
    GUICtrlSetColor($iLabel, $iColor * 0x10000 + $iColor * 0x100 + $iColor)
    $iColor += $iDir
    If $iColor > 0xFD Then
        GUICtrlSetData($iLabel, $aText[Mod($c, 2)])
        $c += 1
        $iDir *= -1
    ElseIf $iColor < 0x02 Then
        $iDir *= -1
    EndIf
EndFunc   ;==>LabelFader

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thanks guys. That'll help.

UEZ - If I use your code, when I try and add a background image using GUICtrlCreatePic, things get all whacky. Am I missing something simple?

And if I can't get it to work I'll probably drop back to doing another GUI on top like Guinness suggested.

Link to comment
Share on other sites

Then try this here:

 

 

#AutoIt3Wrapper_Version=beta ;should be at least AutoIt version 3.3.9.21+
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPITheme.au3>

Const $STM_SETIMAGE = 0x0172
_GDIPlus_Startup()
$hGUI = GUICreate("Test", 468, 324)
$iLabel = GUICtrlCreatePic("c:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 468, 323)
GUICtrlSetState(-1, $GUI_DISABLE)
$iButton = GUICtrlCreateButton("Button", 17, 23, 70, 67)
$iInput = GUICtrlCreateInput("Input", 109, 28, 338, 62)
$iRadio = GUICtrlCreateRadio("Radio", 17, 114, 78, 18)
_WinAPI_SetWindowTheme(GUICtrlGetHandle($iRadio), "", "")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$iRadio2 = GUICtrlCreateRadio("Radio", 17, 140, 55, 19)
_WinAPI_SetWindowTheme(GUICtrlGetHandle($iRadio2), "", "")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$iCheckbox = GUICtrlCreateCheckbox("Checkbox", 109, 114, 83, 18)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
_WinAPI_SetWindowTheme(GUICtrlGetHandle($iCheckbox), "", "")
$iProgress = GUICtrlCreateProgress(109, 140, 338, 29)
GUICtrlSetData(-1, 50)
$iLabel_Pseudo = GUICtrlCreatePic("", 17, 184, 430, 88)
$iButton2 = GUICtrlCreateButton("Exit", 391, 284, 56, 29)
GUISetState()

AdlibRegister("LabelFader", 13)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $iButton2
            AdlibUnRegister("LabelFader")
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
WEnd

Func LabelFader()
    Local Static $iColor = 0x00, $iDir = 2, $c = 0
    Local $aText[2] = ["AutoIt rulez!", "coded by UEZ"]
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $iColor * 0x10000 + $iColor * 0x100 + $iColor)
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0(430, 88)
    Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT)
    _GDIPlus_GraphicsClear($hCtxt, 0xFFFFFFFF)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Comic Sans MS")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 45)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 430, 88)
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    $iColor += $iDir
    If $iColor > 0xFD Then
        $c += 1
        $iDir *= -1
    ElseIf $iColor < 0x02 Then
        $iDir *= -1
    EndIf
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $aText[Mod($c, 2)], $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_GraphicsDispose($hCtxt)
    Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iLabel_Pseudo, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap))
    _WinAPI_DeleteObject($hHBitmap)
EndFunc   ;==>LabelFader
 

AutoIt version 3.3.9.21+ is required

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 3 weeks later...

Thanks for the example UEZ. I haven't done much with GDI+ just yet, so I'm still trying to understand some of the code :) Is there any way to have the LabelFader text appear with a transparent background (instead of the white box as shown in your example) over the top of the background image? I'm going to keep digging into the code to see if I can figure it out, but thought I'd post in case it was an easy answer (although my Google-fu is failing me so far).

Link to comment
Share on other sites

Try this:
 

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

Const $STM_SETIMAGE = 0x0172
_GDIPlus_Startup()
$hGUI = GUICreate("Test", 468, 324)
$iLabel = GUICtrlCreatePic(@ProgramFilesDir & "\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 468, 323)
GUICtrlSetState(-1, $GUI_DISABLE)
$iButton = GUICtrlCreateButton("Button", 17, 23, 70, 67)
$iInput = GUICtrlCreateInput("Input", 109, 28, 338, 62)
$iRadio = GUICtrlCreateRadio("Radio", 17, 114, 78, 18)
_WinAPI_SetWindowTheme(GUICtrlGetHandle($iRadio), "", "")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$iRadio2 = GUICtrlCreateRadio("Radio", 17, 140, 55, 19)
_WinAPI_SetWindowTheme(GUICtrlGetHandle($iRadio2), "", "")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
$iCheckbox = GUICtrlCreateCheckbox("Checkbox", 109, 114, 83, 18)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
_WinAPI_SetWindowTheme(GUICtrlGetHandle($iCheckbox), "", "")
$iProgress = GUICtrlCreateProgress(109, 140, 338, 29)
GUICtrlSetData(-1, 50)
$iLabel_Pseudo = GUICtrlCreatePic("", 17, 184, 430, 88)
$iButton2 = GUICtrlCreateButton("Exit", 391, 284, 56, 29)
GUISetState()

AdlibRegister("LabelFader", 13)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $iButton2
            AdlibUnRegister("LabelFader")
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
WEnd

Func LabelFader()
    Local Static $iColor = 0x00, $iDir = 2, $c = 0, $iMod, $iPrev
    Local $aText[2] = ["AutoIt rulez!", "coded by UEZ"]
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $iColor * 0x10000 + $iColor * 0x100 + $iColor)
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0(430, 88)
    Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT)
;~     _GDIPlus_GraphicsClear($hCtxt, 0xFFFFFFFF)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Comic Sans MS")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 45)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 430, 88)
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    $iColor += $iDir
    If $iColor > 0xFD Then
        $c += 1
        $iDir *= -1
    ElseIf $iColor < 0x02 Then
        $iDir *= -1
    EndIf
    $iPrev = $iMod
    $iMod = Mod($c, 2)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $aText[$iMod], $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_GraphicsDispose($hCtxt)
    Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    If $iPrev <> $iMod Then _WinAPI_DeleteObject(GUICtrlSendMsg($iLabel_Pseudo, $STM_SETIMAGE, $IMAGE_BITMAP, 0)) ;may cause a short flicker on the pic control
    _WinAPI_DeleteObject(GUICtrlSendMsg($iLabel_Pseudo, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap))
    _WinAPI_DeleteObject($hHBitmap)
EndFunc   ;==>LabelFader

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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