Sign in to follow this  
Followers 0
oleg

Put An End To A Flicker

12 posts in this topic

Hi i got a script that constantly updates a Label text .

For some reason it always flicker once i a while . Label is transparent when it flickers i get grey backround on it :mellow: By @sw_enable and @sw_disble gui helped but still flicker comes back again sometime . Any :) ?


There is a hex ( 31303030303030 ) reasons i love AutoIt !

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi i got a script that constantly updates a Label text .

For some reason it always flicker once i a while . Label is transparent when it flickers i get grey backround on it :mellow: By @sw_enable and @sw_disble gui helped but still flicker comes back again sometime . Any :) ?

Constantly updating a label it will flicker, you should set it to only update if it were different than previous.

Example:

Global $DontFlicker = 'This is going to be where we save GUICTRLREAD()'

While 1
    If Not StringInString(GUICtrlRead($Label), $DontFlicker) Then
        GUICtrlSetData($Label, $Data)
        $DontFlicker = GUICtrlRead($Label)
    EndIf
WEnd
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

@Smoke_N: One small mistake in your code:

Global = $DontFlicker = 'This is going to be where we save GUICTRLREAD()'

Corrected Code:

Global $DontFlicker = 'This is going to be where we save GUICTRLREAD()'

While 1
    If Not StringInString(GUICtrlRead($Label), $DontFlicker) Then
        GUICtrlSetData($Label, $Data)
        $DontFlicker = GUICtrlRead($Label)
    EndIf
WEnd

#)

Share this post


Link to post
Share on other sites

@Smoke_N: One small mistake in your code:

Global = $DontFlicker = 'This is going to be where we save GUICTRLREAD()'

Corrected Code:

Global $DontFlicker = 'This is going to be where we save GUICTRLREAD()'

While 1
    If Not StringInString(GUICtrlRead($Label), $DontFlicker) Then
        GUICtrlSetData($Label, $Data)
        $DontFlicker = GUICtrlRead($Label)
    EndIf
WEnd

#)

Yeah, that's what happens when you try to help when you've just gotten up from a Nyquil nap... Thanks, fixed example.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

While ProcessExists("TRANSFER.EXE")

Sleep(500)

;GUISetState(@SW_DISABLE,$MAIN_GUI)

;GUISetState(@SW_DISABLE,$TOOLBAR)

;$OUTPUT = StdoutRead ($OUT)

$PREC = $SIZE / 100

;Transfer and WMI Procedures

$objWMIService = ObjGet ("winmgmts:\\localhost\root\CIMV2")

$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process " & " where Name = ""transfer.exe""", "WQL", 0x10 + 0x20)

If IsObj ($colItems) Then

For $objItem in $colItems

$TRANSFERED = $objItem.WriteTransferCount / 1024 / 1024 / $PREC

$PERCENTAGE = Round($TRANSFERED, 1)

$OVERALL = $objItem.WriteTransferCount / 1024 / 1024

$MBOVERALL = Round($OVERALL, 1)

;Main Window Progress

GUICtrlSetData($MAIN_PROGRESS, $PERCENTAGE)

GUICtrlSetData($MAIN_STATUS, "Installing Files Please Wait | Transfered : " & $PERCENTAGE & "%" & " " & $MBOVERALL & " MB Overall")

;GUISetState(@SW_ENABLE,$MAIN_STATUS)

;Tray Progress

TrayTip("Gloader", $PERCENTAGE & "% Transfered", "", 16)

;Tool Progress

GUICtrlSetData($TOOLPROGRESS, $PERCENTAGE)

GUICtrlSetData($TOOLSTATUS, "Installing Files")

GUICtrlSetData($TOOLPRC, $PERCENTAGE)

;GUISetState(@SW_ENABLE,$MAIN_GUI)

;GUISetState(@SW_ENABLE,$TOOLBAR)

Next

EndIf

WEnd

There is no need to check if anything changed because it dose change every 500 ms :)

What do you think ?

GUICtrlSetData($MAIN_STATUS, "Installing Files Please Wait | Transfered : " & $PERCENTAGE & "%" & " " & $MBOVERALL & " MB Overall") < this is the problem :mellow:

Edited by oleg

There is a hex ( 31303030303030 ) reasons i love AutoIt !

Share this post


Link to post
Share on other sites

I tried to replicate it... I don't get a flicker with this, but my pc is pretty fast:

$main = GUICreate('Test Label', 200, 100)
$label = GUICtrlCreateLabel('', 10, 10, 50, 20)
GUICtrlSetColor($label, 0xFF0000)
GUICtrlSetBkColor($label, 0xFFFFFF)

GUISetState()
Local $Count = 0

While 1
    Sleep(500)
    $Count += 1
    GUICtrlSetData($label, $Count)
WEnd


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Then try updating it every 2 seconds

$time = TimerStart()
while 1
   If TimerDiff($time) >= 2000 Then
      $time = TimerStart()
     ;;;PUT UPDATE CODE HERE!!!
   EndIf
wend

Something like that... i think...

#)

Share this post


Link to post
Share on other sites

@Smoke_N: One small mistake in your code:

Global = $DontFlicker = 'This is going to be where we save GUICTRLREAD()'

Corrected Code:

Global $DontFlicker = 'This is going to be where we save GUICTRLREAD()'

While 1
    If Not StringInString(GUICtrlRead($Label), $DontFlicker) Then
        GUICtrlSetData($Label, $Data)
        $DontFlicker = GUICtrlRead($Label)
    EndIf
WEnd

#)

I also noticed you wrote StringinString, it should be String inStr

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

I also noticed you wrote StringinString, it should be String inStr

:), nice ... as I stated, been sick lately... and the nyquil is worse than alcohol sometimes.... I think the end-user would have figured those out, but yes... you are correct.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

:), nice ... as I stated, been sick lately... and the nyquil is worse than alcohol sometimes.... I think the end-user would have figured those out, but yes... you are correct.

:mellow: Yes it took 0.1 ms to figure it out but still i cant get rid of the flicker :)


There is a hex ( 31303030303030 ) reasons i love AutoIt !

Share this post


Link to post
Share on other sites

a small change to "SmOke_N" code, no flicker for me

$main = GUICreate('Test Label', 200, 100)
$label = GUICtrlCreateLabel('', 10, 10, 50, 20)
GUICtrlSetColor($label, 0xFF0000)
GUICtrlSetBkColor($label, 0xFFFFFF)

GUISetState()
Local $Count = 0

While 1
    Sleep(500)
    $Count = $count + 1
    ControlSetText("Test Label", "", "Static1", $count)
WEnd

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I tried to replicate it... I don't get a flicker with this, but my pc is pretty fast:

$main = GUICreate('Test Label', 200, 100)
$label = GUICtrlCreateLabel('', 10, 10, 50, 20)
GUICtrlSetColor($label, 0xFF0000)
GUICtrlSetBkColor($label, 0xFFFFFF)

GUISetState()
Local $Count = 0

While 1
    Sleep(500)
    $Count += 1
    GUICtrlSetData($label, $Count)
WEnd

How about using ControlSetText? A tip from SplashTextOn help section.

$main = GUICreate('Test Label', 200, 100)
$label = GUICtrlCreateLabel('', 10, 10, 50, 20)
GUICtrlSetColor($label, 0xFF0000)
GUICtrlSetBkColor($label, 0xFFFFFF)

GUISetState()
Local $Count = 0

While 1
    Sleep(500)
    $Count += 1
    ControlSetText($main,"",$label, $Count)
WEnd
Edited by Joon

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