Jump to content

Put An End To A Flicker


oleg
 Share

Recommended Posts

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 !

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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

#)

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
Share on other sites

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 !

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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...

#)

Link to comment
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.
Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
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 !

Link to comment
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
Link to comment
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

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