Jump to content

Smart Way to use AdlibRegister for SplashText


Go to solution Solved by JohnOne,

Recommended Posts

I just finally figured out how to do an easy thing, put AdlibRegister in my script as a timeout incase something fails..

I also tested today using a full screen splashtext to hide automation work being done by a script, and that worked well.

Now I am trying to sort of tie the two together just for fun.  My goal is to have splashtext update on a regular interval so you can read it and be entertained while a script runs in the background.  This way the text flows on a regular pace rather than being randomly inserted into the script.

I have it working... but I know there must be a smarter way than this, I feel like this is more code than should be needed and am looking for alternative ways to set this up with easy code.

AdlibRegister("UpdateText", 4000)
SplashTextOn("mytext", "Text1")

$Roll = 1
Func UpdateText()
    Switch $Roll
        Case 1
            ControlSetText("mytext", "", "Static1", "Text2")
            $Roll += 1
        Case 2
            ControlSetText("mytext", "", "Static1", "Text3")
            $Roll += 1
        Case 3
            ControlSetText("mytext", "", "Static1", "Text4")
            $Roll += 1
        Case 4
            ControlSetText("mytext", "", "Static1", "Text5")
            $Roll += 1
        Case 5
            ControlSetText("mytext", "", "Static1", "Text6")
            $Roll += 1
    EndSwitch
    EndFunc

    Sleep(30000)

If there is not much a better way I do not mind this, it works.  I just would want to also have an Exit at some point for a time out value.  Can you run more than one function with AdlibRegister at the same time?  If not I guess I would need to add a time based timerinit() exit or something to the existing function.

Regards,

Link to comment
Share on other sites

AdlibRegister("UpdateText", 1000)
SplashTextOn("mytext", "Text1")

Func UpdateText()
    Local Static $Roll = 2
    ControlSetText("mytext", "", "Static1", "Text" & $Roll)
    $Roll += 1
EndFunc   ;==>UpdateText

Sleep(10000)

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Solution

AdlibRegister("UpdateText", 1000)
SplashTextOn("mytext", "Hilarious things")

Func UpdateText()
    Local Static $aRoll[4] = ["Scrotum", _
            "Funny bone", _
            "Fanny Cradock", _
            "Anal sphincter"]
    ControlSetText("mytext", "", "Static1", $aRoll[Random(0, 3, 1)])
EndFunc   ;==>UpdateText

Sleep(10000)

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...