User0101

SplashTextOn Updates Without Flicker

5 posts in this topic

Situation: I have a process where files are downloaded to a specific location on a device and then get applied by a 3rd party program. I have a SplashTextOn popup notifying the user with a simple file count letting them see when files are downloaded and then later applying. The user see's the numbers count up and then down. Currently this SplashTextOn popup works with one small hiccup I'd like to try to solve. The script updates once per second to display the file count, as a result there is a slight flicker with the SplashTextOn popup. I've followed many examples and have tried everything that I know how from the AutoIt Help Document as well as exhaustive searching. It's possible the solution is quite simple but it's just out of my mental reach at the moment.

Goal: Display the popup window with the file count that updates once per second, or when a change is detected with the number of files in the specific directory, and eliminate any popup flicker if possible.

Here is what I have with some small changes to protect sensitive info. I would appreciate any tips you can provide and thank you for your help.

AutoItSetOption("WinWaitDelay", 500)        
AutoItSetOption("WinTitleMatchMode",1)      
AutoItSetOption("WinDetectHiddenText",1)    
AutoItSetOption("TrayIconDebug", 1)         
AutoItSetOption("TrayIconHide", 0)          
HotKeySet("{ESC}", "_Terminate")            
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

;   Build The Active Count Function & Splash Message
Func SyncFileCount()
    $path = "C:\XXXXX\Messages\"
    $count = DirGetSize($path, 1)
    $msg = ""

    SplashTextOn("Sync File Count", $msg, 380, 46, -1, -1, 1, "", 14)
        $msg = $msg & $count[1]
        ControlSetText("Sync File Count", "", "Static1", "Synchronization Files Being Processed " & $msg)
        Sleep(1000)
EndFunc

;   Call The File Count Function
While 1
    $path = "C:\XXXXX\Messages\"
    $count = DirGetSize($path, 1)

    Call("SyncFileCount")
WEnd

Exit

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try it this way:

$sReturn = Execute("@Gui_CtrlID")
ConsoleWrite($sReturn&@CRLF)AutoItSetOption("WinWaitDelay", 500)        
AutoItSetOption("WinTitleMatchMode",1)      
AutoItSetOption("WinDetectHiddenText",1)    
AutoItSetOption("TrayIconDebug", 1)         
AutoItSetOption("TrayIconHide", 0)          
HotKeySet("{ESC}", "_Terminate")            
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

Global $bAllDone=False  ;<== this var is set to True when Sync is done

SyncFileCount()

;   Build The Active Count Function & Splash Message
Func SyncFileCount()
    AdlibUnRegister('SyncFileCount')
    `Local $path = "C:\XXXXX\Messages\"
    Local $count = DirGetSize($path, 1)
    Local Static $oldCount
    Local $msg = ""
    If $oldCount <> $Count Then
    SplashTextOn("Sync File Count", $msg, 380, 46, -1, -1, 1, "", 14)
        $msg = $msg & $count[1]
        ControlSetText("Sync File Count", "", "Static1", "Synchronization Files Being Processed " & $msg)
    EndIf
    $oldCount = $count
    AdlibRegister('SyncFileCount',1000)
EndFunc

;   Call The File Count Function
Do
    Sleep(1000)
Until $bAllDone

Exit

 

Edited by AutoBert

Share this post


Link to post
Share on other sites

AutoBert,

First let me thank you extensively for such a detailed response. There are some things going on in your code that I look forward to learning more about that I haven't incorporated in my other projects. When updating your suggestion with the correct directory structure, not the XXXXX that I have listed, I unfortunately still get the flicker. The file count function does work all the same as it detects anything new I place there or when something is deleted. But you do still have the flicker once per second.

I've been exploring full blown GUI versions of this popup to experiment with in case this sort of thing could not be done and while new at the GUI side of AutoIt I've had some limited growth. But that's a longer term goal anyway. Again, thank you for your efforts and your time.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ControlSetText() should update without the flash, just make sure you do not call SplashTextOn() again only once to start the element and then from that point onward just update it. 

This should clearly demonstrate the problem and solution:

SplashTextOn("test", "First Line of Text")
Sleep(1000)
SplashTextOn("test", "First Line of Text")
Sleep(1000)
SplashTextOn("test", "Second Line of Text")
Sleep(1000)
SplashTextOn("test", "Second Line of Text")
Sleep(1000)
SplashTextOn("test", "Third Line of Text")
Sleep(1000)
SplashTextOn("test", "Third Line of Text")
Sleep(1000)
ControlSetText("test", "", "Static1", "Fourth Line of Text")
Sleep(1000)
ControlSetText("test", "", "Static1", "Fourth Line of Text")
Sleep(1000)
ControlSetText("test", "", "Static1", "Fifth Line of Text")
Sleep(1000)
ControlSetText("test", "", "Static1", "Fifth Line of Text")
Sleep(1000)

or since your using a loop of sorts, this may make it even more clear and show more than one to solve the issue.

 

;Loop using SplashTextOn() will flicker by recreating the element
For $i = 1 to 10
    SplashTextOn("test", "Text For Loop " & $i)
    Sleep(500)
    SplashTextOn("test", "Text For Loop " & $i)
    Sleep(500)
Next

SplashOff()

;Loop that only updates the text with ControlSetText() will not flicker, element is created before the loop
SplashTextOn("test", "")
For $i = 1 to 10
    ControlSetText("test", "", "Static1", "Text For Loop " & $i)
    Sleep(500)
    ControlSetText("test", "", "Static1", "Text For Loop " & $i)
    Sleep(500)
Next

SplashOff()

;Loop that contains SplashTextOn() in the loop but uses an if statment to not recreate it if it already exists.
For $i = 1 to 10
    If NOT WinExists("test", "")  Then SplashTextOn("test", "" & $i)
    ControlSetText("test", "", "Static1", "Text For Loop " & $i)
    Sleep(500)
    If NOT WinExists("test", "")  Then SplashTextOn("test", "" & $i)
    ControlSetText("test", "", "Static1", "Text For Loop " & $i)
    Sleep(500)
Next

 

Edited by ViciousXUSMC

Share this post


Link to post
Share on other sites

ViciousXUSMC,

Thank you for your comments and suggestions. I'm tested several of your versions now to see how I can accomplish the directory file count, call the SplashTextOn only once, and update the text with ControlSetText without flicker. The loop is there because a 3rd party app will be running during this entire script which is what is downloading and then applying files to that special directory on our devices. Once the app is finished the script detects that the process has closed and then exits the loop and script.

By removing those additional bits and simply testing the file count and text display options available to us is how I can quickly see if it works. I have many junk test files setup in a temp directory that I'm using to test these scenarios that way I don't effect my live environment if you will.

Again, thank you for your suggestions. I'm testing further now.

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

  • Similar Content

    • MarkBe
      By MarkBe
      I run a compiled .exe as a group policy shutdown script to update various software. The function below is called to run both .exe and .msi installers (hence the two sections). When I run this in a user session the SplashTextOn window stays visible in the background throughout the entire install but when this is executed as a shutdown script the SplashTextOn window disappears before the installer has finished (during the RunWait)
      Func _InstallSW() SplashTextOn("Installing", $InstallingUpdateMessage, 500, 400, -1, -1, $DLG_NOTONTOP) FileCopy ($SourcePath & $SWInstaller, $WorkingDirectory & $SWInstaller, $FC_OVERWRITE + $FC_CREATEPATH) If StringLower(StringRight($SWInstaller, 4))=".exe" Then RunWait ('"' & $WorkingDirectory & $SWInstaller & '"' & $InstallerSwitches) Else RunWait ('msiexec /i "' & $WorkingDirectory & $SWInstaller & '"' & $InstallerSwitches) EndIf SplashOff() EndFunc ;==>InstallSW Is there a better function to use or something I can add (e.g. While)? I need it to remain behind the installer's progress windows so it shows when the installer is running a background process (to prevent the user from forcing the power off thinking it has hung)