Sign in to follow this  
Followers 0

Best way to create an horizontal scrolling text ?


15 posts in this topic

#1 ·  Posted

Hi all,

I'd like to create a simple way to diffuse some text messages at the bottom of a screen from right to left on the entire width in continue.

Goal is to diffuse message to my company's people on a 16/9 TV in a continue way. Messages would be taken from text files created in a specified directory....

How could i do this with AutoIT ?

thanks a lot for your help.

Florent

Share this post


Link to post
Share on other sites



#2 ·  Posted

fgilain,

Look at the Marquee UDF in my sig - should do what you want. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert - Easily convert date/time formats, including the language used
ExtMsgBox ------------- A highly customisable replacement for MsgBox
GUIExtender ----------- Extend and retract multiple sections within a GUI
GUIFrame -------------- Subdivide GUIs into many adjustable frames
GUIListViewEx -------- Insert, delete, move, drag, sort and edit ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ---------------- Scrolling tickertape GUIs
NoFocusLines --------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify -------------------- Small notifications on the edge of the display
Scrollbars -------------- Automatically sized scrollbars with a single command
StringSize -------------- Automatically size controls to fit text
Toast -------------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Here another example:

Simple Horizontal Label Scroller.au3 Simple Horizontal Label Scroller.au3

;coded by UEZ 2012 build 2012-03-09
#include <windowsconstants.au3>
#include "Scroller.au3"

$iW = 640
$iH = Int($iW * 9 / 16)
$hGUI = GUICreate("Simple Horizontal Scroller", $iW, $iH, -1, -1, Default, $WS_EX_COMPOSITED)
GUISetState()

$sText = "This is a simple horizontal scroller made with AutoIt using a label! Using this technique is not the best way because label is flickering :-("

$aHScroller1= Scroller_Init($hGUI, 64, $sText, "Arial", 96, 0, 0x006000, False, False, 0xABCDEF)
If @error Then Exit MsgBox(16, "ERROR", "Unable to initiate scroller", 10)

$aHScroller2= Scroller_Init($hGUI, $iH - 64, $sText, "Comic Sans MS", 24, 0, 0, True, True)
If @error Then Exit MsgBox(16, "ERROR", "Unable to initiate scroller", 10)

HotKeySet("{F1}", "Init_Scroller_Off")
HotKeySet("{F2}", "Init_Scroller_On")
HotKeySet("{F3}", "Init_Scroller_Reset")

AdlibRegister("Scroll_It", 30)

Do
Until GUIGetMsg() = -3

_Exit()

Func Scroll_It()
    Scroller_Move($aHScroller1, 1.25)
    Scroller_Move($aHScroller2, 1)
EndFunc

Func Init_Scroller_Off()
    Scroller_Off($aHScroller1[0])
EndFunc

Func Init_Scroller_On()
    Scroller_On($aHScroller1[0])
EndFunc

Func Init_Scroller_Reset()
    Scroller_Reset($aHScroller1)
EndFunc

Func _Exit()
    AdlibUnRegister("Scroll_It")
    GUIDelete($hGUI)
    Exit
EndFunc

Scroller.au3 Scroller.au3

;coded by UEZ 2012 build 2012-03-11
#include-once
#include <guiconstantsex.au3>
#include <staticconstants.au3>
#include <gdiplus.au3>

Func Scroller_Init($hGUI, $iY, $sText, $sFont = "Arial", $iFSize = 24, $iFStyle = 0, $iFColor = 0x000000, $hl = False, $bgc = False, $bgcolor = 0xFEDCBA)
    If Not IsHWnd($hGUI) Then Return SetError(1, 0, 0)
    If $sText = "" Then Return SetError(2, 0, 0)
    Local $aSize = WinGetClientSize($hGUI)
    Local $aStringSize =  GetStringSize($sText, $sFont, $iFSize, $iFStyle)
    Local $idLabel_Scroller = GUICtrlCreateLabel($sText, $aSize[0], $iY, $aStringSize[0], $aStringSize[1])
    Local $fWeight = 400
    If BitAND($iFStyle, 1) Then $fWeight = 800
    GUICtrlSetFont($idLabel_Scroller, $iFSize, $fWeight , BitXOR($iFStyle, 1), $sFont, 4)
    GUICtrlSetColor($idLabel_Scroller, $iFColor)
    If $bgc Then
        Local $idLabel_BG = GUICtrlCreateLabel("", 0, $iY - 3, $aSize[0], $aStringSize[1] + 3)
        GUICtrlSetBkColor($idLabel_BG, $bgcolor)
        GUICtrlSetState($idLabel_BG, $GUI_DISABLE)
        GUICtrlSetBkColor($idLabel_Scroller, $bgcolor)
    EndIf
    If $hl Then
        Local $idLabel_HorizontalLine1 = GUICtrlCreateLabel("", 0, $iY - 4, $aSize[0] + 4, 2, $SS_ETCHEDHORZ)
        Local $idLabel_HorizontalLine2 = GUICtrlCreateLabel("", 0, $iY + $aStringSize[1], $aSize[0] + 4, 2, $SS_ETCHEDHORZ)
    EndIf
    Local $aData[4] = [$idLabel_Scroller, $aStringSize[0], $aSize[0] + $iFSize, $aSize[0] + $iFSize] ;id label, string width, gui width, $iPos
    Return $aData
EndFunc

Func Scroller_Off($idControl)
    GUICtrlSetState($idControl, $GUI_HIDE)
EndFunc

Func Scroller_On($idControl)
    GUICtrlSetState($idControl, $GUI_SHOW)
EndFunc

Func Scroller_Reset(ByRef $aData)
    $aData[3] = $aData[2]
EndFunc

Func Scroller_Move(ByRef $aData, $iSpeed = 1)
    $aData[3] -= $iSpeed
    GUICtrlSetPos($aData[0], $aData[3])
    If $aData[3] < -$aData[1] Then $aData[3] = $aData[2]
EndFunc

Func GetStringSize($string, $font, $fontsize, $fontstyle)
    Local $GDIp = False
    Local $iWidth = StringLen($string) * $fontsize
    Local $iHeight = 2 * $fontsize
    If Not $ghGDIPDll Then
        _GDIPlus_Startup()
        $GDIp = True
    EndIf
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int",  0x0026200A, "ptr", 0, "int*", 0)
    Local $hBitmap = $aResult[6]
    Local $hGrphContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate($font)
    Local $hFont = _GDIPlus_FontCreate($hFamily, $fontsize, $fontstyle)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGrphContext, $string, $hFont, $tLayout, $hFormat)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGrphContext)
    If $GDIp Then _GDIPlus_Shutdown()
    Local $aDim[2] = [Int(DllStructGetData($aInfo[0], "Width")), Int(DllStructGetData($aInfo[0], "Height"))]
    Return $aDim
EndFunc

Br,

UEZ

Edited by UEZ

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

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Share this post


Link to post
Share on other sites

#5 ·  Posted

Anybody else with same problem?

@Belini: Did you modify something?

Br,

UEZ


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

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#6 ·  Posted

Share this post


Link to post
Share on other sites

#7 ·  Posted

Anybody else with same problem?

@Belini: Did you modify something?

Br,

UEZ

Works for me on Windows 7 x64 using AutoIt V3.3.9.1.

UDF List:

 

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

 

 

Updated: 02/04/2015

Share this post


Link to post
Share on other sites

#8 ·  Posted

I tried it on Win 7 running both AutoIt 3.3.8.1 and 3.3.9.1, using both x64 and x86 and it worked for me.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#9 ·  Posted

I cannot imagine what could be wrong with Belini's pc....

Thanks for testing!

Br,

UEZ


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

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#10 ·  Posted

I guess he's using Windows XP but no idea what service pack etc...


UDF List:

 

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

 

 

Updated: 02/04/2015

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I tried it on Win 7 running both AutoIt 3.3.8.1 and 3.3.9.1, using both x64 and x86 and it worked for me.

Windows XP Spack2

@ UEZ do not think you understand, I want only to appear a screen part, I do not want the whole screen

The image is an example of what I want

Edited by Belini

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

The screen shot he attached was for to show you how he want it to be, he didn't said your script appears like that, he said he want it to be like that.

Edited by D4RKON3

I felt in love with AutoItObject [and the new Map type!].

Share this post


Link to post
Share on other sites

#13 ·  Posted

Sorry, I misunderstood what you want to ask!

That's not easily possible because here the whole label is moving from right to left and it cannot be implemented as shown in the screenshot.

One possibility might be creating 2 topmost child windows with appropriate size and height which overlap the left and right part of the scroller.

This could give the illusion that the scroller is only in a middle part of the gui.

Br,

UEZ


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

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#14 ·  Posted

UEZ,

I thought the same as you and probably everyone else did on the forum, that Belini had a problem with your UDF not requesting a new feature to be added.


UDF List:

 

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

 

 

Updated: 02/04/2015

Share this post


Link to post
Share on other sites

#15 ·  Posted

Share this post


Link to post
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
Sign in to follow this  
Followers 0