Sign in to follow this  
Followers 0
jokke

Rolling text.

4 posts in this topic

#1 ·  Posted (edited)

Hi everyone, im trying to create a text animation, where text rolles past a label iwe made, but are having problems with flickering.

I'we tried updating the label less often but it still flicker's sometimes, does anyone have any tip for what i should do?

Posted Image

Heres a snippet from what im trying to achieve:

#include <GUIConstants.au3>

Global $rollingtitle[6]

$GUI = GUICreate("Test gui", 220, 40, -1, -1)
GUISetBkColor(0x000000)

$label =    GUICtrlCreateLabel("Button",5,10,210,15)
            GUICtrlSetColor(-1,0xFFFFFF)
            GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetCursor(-1, 0)

GUISetState()


While 1
    $nMsg = GUIGetMsg($GUI)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    
    RollingText($label,"Visit our brand new page, for new content @ http://website.com  ***  ")

    
WEnd

Func RollingText($hWid,$text)
    If TimerDiff($rollingtitle[5]) > 300 Then
        $rollingtitle[2]    = 40
        $rollingtitle[3] += 1
        
        If $rollingtitle[3] > StringLen($text) Then $rollingtitle[3] = 0
        
        $rollingtitle[4]    = StringMid($text,$rollingtitle[3],$rollingtitle[2])
        
        If StringLen($rollingtitle[4]) < $rollingtitle[2] Then 
            $rollingtitle[4] = $rollingtitle[4] & StringLeft($text,$rollingtitle[2] - StringLen($rollingtitle[4]))
        EndIf
        
        GUICtrlSetData($hWid,$rollingtitle[4],"")
        
        $rollingtitle[5] = TimerInit()
    EndIf
EndFunc
Edited by jokke

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites



Kind of silly to set a value in $timer[1], but ignore it in the RollingText function, isn't it? :)

I don't know how to solve the flickering, in fact I dare say it simply can't be helped, but I would like to suggest looking at the new _Timer functions included in the beta, they could help you simplify your overall script.

Share this post


Link to post
Share on other sites

Oh my bad i added that timer whitout thinking, inn my actual script i dont have the RollingText() function wrapped in a timer.

I remember i have seen a dll file for injecting data into identifier (controlID) of controlls once (maybe it'll work better?), but i cant remeber inn what situation it was used. Thus giving me thousands upon thousands of posts to look through.


UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.

Share this post


Link to post
Share on other sites

Here's another option, (though I can't really see any flicker with your original so I don't know how this will compare)

#include <GUIConstants.au3>

Global $labelX = 5, $labelY = 10, $labelW = 350, $labelH = 15
$rollingText = "Visit our brand new page, for new content @ http://website.com  ***  "

$GUI = GUICreate("Test gui", 220, 40, -1, -1)
GUISetBkColor(0x000000)


$label = GUICtrlCreateLabel($rollingText, $labelX, $labelY, $labelW, $labelH)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 0)

$label2 = GUICtrlCreateLabel($rollingText, $labelX + $labelW, 10, $labelW, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 0)

GUISetState()
$sTime = TimerInit()
$NewLabelX = $labelX
$NewLabel2X = $NewLabelX + $labelW
$labelScroll = 1

While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    RollingText()
WEnd

Func RollingText()
    If TimerDiff($sTime) > 50 Then
        $sTime = TimerInit()
        $NewLabelX -= $labelScroll
        $NewLabel2X -= $labelScroll
        If $NewLabelX <= (-$labelX - $labelW) Then
            $label2Pos = ControlGetPos($GUI, "", $label2)
            $NewLabelX = $label2Pos[0] + $labelW
        EndIf
        If $NewLabel2X <= (-$labelX - $labelW) Then
            $labelPos = ControlGetPos($GUI, "", $label)
            $NewLabel2X = $labelPos[0] + $labelW
        EndIf
        ControlMove($GUI, "", $label, $NewLabelX, 10)
        ControlMove($GUI, "", $label2, $NewLabel2X, 10)
    EndIf
EndFunc

Of course, the problem with this is the length of your $rollingtext string and getting the size of the label right, especially if you don't specify a font and the user has some custom theme/font size turned on. Although you might be able to combine it with jerome's Fit string to label or figure out the reverse, a fit label to string.

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