Jump to content
Sign in to follow this  

Smooth scrolling label text

Recommended Posts

Hi All

I'm new to the forum and have been using AutoIt for almost a full day now! The (hopefully) attached code shows how I'm trying to simulate smooth-scrolling text. (Forget about the messy way I read in a text file - I've since found FileReadLine() and StringSplit() ) This method works in principle - quite well in fact if the label occupies the full window height.

But what I'm trying to do is confine the scrolling area by using other controls. I've tried constraining the label in a Group frame (no joy) and (in this case) "blocking things off" with another empty label that I'm trying to maintain as opaque to the text. I'd appreciate any better techniques that anyone might know of.

thanks, and glad to be invited in


#include <GuiConstants.au3>
$file = FileOpen("C:\test.txt", 0)
$text = ""

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")

; Read in 1 line at a time until the EOF is reached
for $i = 1 to 120
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    $text = $text & $line & @LF

$len = StringLen($text)
$GUI_Handle = GuiCreate("MyGUI", 400, 400,(@DesktopWidth-400)/2, (@DesktopHeight-400)/2)
$Label_1 = GuiCtrlCreateLabel($text, 90, 110, 2300, 1700)
$Label_2 = GuiCtrlCreateLabel("", 0, 0, 1700, 109)


; Simulate smooth scrolling by slowly repositioning $Label_1
While 1
    For $i = 0 to $len
        GUICtrlSetPos($Label_1, 9, 110 - $i)
        GUICtrlSetPos($Label_2, 0, 0)

Edited by AlanR

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...