thawee Posted September 10, 2011 Share Posted September 10, 2011 Func Hello() If $day >1 then $type = "s" $type = " Day" & $type & " " $Output = $day & $type & $hour & ":" & $min &":"& $sec ;& '.'& $msec GUICtrlSetData ($UpTime,"Uptime: " & $Output) ConsoleWrite($Output) Else $Output = $hour & ":" & $min &":"& $sec ;& '.'& $msec GUICtrlSetData ($UpTime, $Output) Endif Endfunc There is a bit more to this code, but this seemed relevant. essentially I am calling the function hello() that calculates my system uptime. The problem I am having is if i do the following outside my function. GuictrlSetData("Uptime: " & Hello()) The information works correctly because I set up the function to pass the variable. however, I was thinking that I wanted the GuiCtrlSetData to up date inside of the function, but when I try to assign use GUICtrlSetData ($UpTime, $Output) my data comes up blank. I have checked the $Output before, and after the function and the output is fine, but every time I changed the GUICtrlSetData ($UpTime, Hello()) to read the data it comes back good. Any Ideas? Its almost like I am not allow to update my label more than once!? Thawee Link to comment Share on other sites More sharing options...
Rogue5099 Posted September 10, 2011 Share Posted September 10, 2011 (edited) Since I didn't want to create a GUI here is a stand alone that returns current time and $days = 3 $hour = @HOUR $min = @MIN $sec = @SEC $day = 3 MsgBox(0, "Test", Hello()) Func Hello() If $day > 1 Then $Output = "Uptime: " & $day & " Days " & $hour & ":" & $min &":"& $sec ;& '.'& $msec Else $Output ="Uptime: " & $hour & ":" & $min &":"& $sec ;& '.'& $msec EndIf ;~ GUICtrlSetData($UpTime, $Output) Return($Output) Endfunc Edited September 10, 2011 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 10, 2011 Moderators Share Posted September 10, 2011 thawee, Without seeing the rest of the code it is difficult to be sure, I would hazard a guess that $UpTime is an undeclared Local variable within your function and so it does not know what control to update. If the update works when you return the value and not when you do it in the function, then this seems a likely cause. What scope do you have set for $UpTime? Is is first declared within another function? If so then you will either need to pass it to the function as a parameter or declare it as Global in scope - I would recommend the former. Do you use Au3Check? It is very helpful in finding scope mismatches like this. Or you can use Opt("MustDeclareVars", 1) to catch the error. Please ask if anything is unclear. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
thawee Posted September 10, 2011 Author Share Posted September 10, 2011 (edited) As it turns out my Menu Declaration was the same as my Variable I used to calculate my system up time which caused my variable to become blank. I was wondering how do i Update my GUI label say every Second without causing a flicker effect? I am currently using GUICtrlSetData Thanks Thawee Edited September 10, 2011 by thawee Link to comment Share on other sites More sharing options...
guinness Posted September 10, 2011 Share Posted September 10, 2011 (edited) Simple, do a check of whether the data has changed to reduce flickering e.g. Global $iControlID, $sRead, $sReadPrevious $iControlID = GUICtrlCreateLabel( ..., ... ) $sRead = GUICtrlRead($iControlID) If $sRead <> $sReadPrevious Then ; Store the label data in a variable to check at a later stage. $sReadPrevious = $sRead GUICtrlSetData($iControlID, $sRead) EndIf Edited September 10, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
thawee Posted September 10, 2011 Author Share Posted September 10, 2011 Cool Thanks, I have also noticed an odd issues. The Text in my label Flickers when i move my mouse over the Gui Window? Does anyone know why its doing this? Thanks Thawee Link to comment Share on other sites More sharing options...
guinness Posted September 10, 2011 Share Posted September 10, 2011 Without seeing any code it really is hard to guess why that is. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
thawee Posted September 10, 2011 Author Share Posted September 10, 2011 (edited) $M_UpTime = GUICtrlCreateLabel("Up Time: ", 400, 16, 209, 21) GUICtrlSetFont(-1, 11, 400, 2, "Gentium Basic") While 1 ; Main Loop $nMsg = GUIGetMsg() If $MenuUpdateCntr >= 400 Then $ChkUptime = GUICtrlRead($M_UpTime) If $ChkUptime <> $Output Then _PCUptime() EndIf $MenuUpdateCntr = 0 EndIf Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $MenuUpdateCntr = $MenuUpdateCntr + 1 WEnd I use the GUICtrlSetData to update my labels. Is the label the best way to put text on a GUI Window? Thawee Edited September 10, 2011 by thawee Link to comment Share on other sites More sharing options...
guinness Posted September 11, 2011 Share Posted September 11, 2011 (edited) _GDIPlus_*() in the Help file. Also for the future & and to be courtesy too, it helps to post workable/runnable code because the example above isn't really giving the whole picture. One bit of advice you can use $MenuUpdateCntr += 1 to increment by 1. Edited September 11, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
thawee Posted September 11, 2011 Author Share Posted September 11, 2011 I apologize, I wasn't trying to be un-courteous. The amount of code to produce the loop segment posted about is quite large to me, so I thought it would be appropriate to reduce it down to what was needed. I will attempt to post working code in the future. Thanks Thawee Link to comment Share on other sites More sharing options...
thawee Posted September 11, 2011 Author Share Posted September 11, 2011 (edited) #include <GuiConstantsEx.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hGUI, $hGraphic ; Create GUI $hGUI = GUICreate("GDI+", 400, 300) GUISetState() ; Draw a string _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI) ;_GDIPlus_GraphicsDrawString ($hGraphic, "Hello world", 140, 110) Used to be active but moved inside loop ; Loop until user exits Do _GDIPlus_GraphicsDrawString ($hGraphic, "Hello world", 140, 110) ;moved this from above the loop. Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_Shutdown () EndFunc ;==>_Main I was looking at GDIPlus, and I tried putting it into my script instead of the GUICtrlSetData and Label format. When I ran this script with the _GDIPlus_GraphicsDrawString ($hGraphic, "Hello world", 140, 110) Inside the loop it produced a Text That was really bolded. I am trying desprately to figure out how to just simply update any text on a gui window without flicker or weird side effects? Sorry for my lack of understand. I have read over the Gdi plus elements, and some of it is very confusing to me. Is there a simple way to refresh gui text data without causing odd side effects..Like the text bolding or flickering? Maybe I am doing it wrong? Thanks Thawee Edited September 11, 2011 by thawee Link to comment Share on other sites More sharing options...
guinness Posted September 11, 2011 Share Posted September 11, 2011 This doesn't flicker on Windows 7 x64. expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> _Main() Func _Main() Local $hGUI, $iLabel, $iTimer, $sReadPrevious, $sText $hGUI = GUICreate("Example not with GDI+", 400, 300) $iLabel = GUICtrlCreateLabel("", 10, 10, 380, 280) GUICtrlSetBkColor(-1, 0x000) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 20) GUISetState(@SW_SHOW, $hGUI) $iTimer = TimerInit() While 1 $sText = _RandomText(50) If $sText <> $sReadPrevious And TimerDiff($iTimer) > 150 Then $iTimer = TimerInit() $sReadPrevious = $sText GUICtrlSetData($iLabel, $sText) EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>_Main Func _RandomText($iLength = 7) Local $sData = "", $sRandom For $A = 1 To $iLength $sRandom = Random(55, 116, 1) $sData &= Chr($sRandom + 6 * ($sRandom > 90) - 7 * ($sRandom < 65)) Next Return $sData EndFunc ;==>_RandomText UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
thawee Posted September 11, 2011 Author Share Posted September 11, 2011 (edited) expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> _Main() Func _Main() Local $hGUI, $iLabel, $iTimer, $sReadPrevious, $sText $hGUI = GUICreate("Example not with GDI+", 400, 300) $iLabel = GUICtrlCreateLabel("", 10, 10, 380, 280) ;GUICtrlSetBkColor(-1, 0x000) ;GUICtrlSetColor(-1, 0xFFFFFF) ;GUICtrlSetFont(-1, 20) GUISetState(@SW_SHOW, $hGUI) $iTimer = TimerInit() While 1 $sText = _RandomText(50) If $sText <> $sReadPrevious And TimerDiff($iTimer) > 150 Then $iTimer = TimerInit() $sReadPrevious = $sText GUICtrlSetData($iLabel,"This is a test of the flicker effect based on the size of the sentence. : " & $sText) EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>_Main Func _RandomText($iLength = 7) Local $sData = "", $sRandom For $A = 1 To $iLength $sRandom = Random(55, 116, 1) $sData = Chr($sRandom + 6 * ($sRandom > 90) - 7 * ($sRandom < 65)) & Chr($sRandom + 6 * ($sRandom > 90) - 7 * ($sRandom < 65)) Next Return $sData EndFunc Here is the modified code that produces a flicker effect for me. Thanks for your help. I have realized that the flicker effect gets worse the long the sentence is. I was thinking of breaking up the 2 segments, so that I would only be updating a small segment Maybe that would clean up most if not all of the flicker effect. Any ideas would be greatly appreciated. Thanks Thawee Edited September 11, 2011 by thawee Link to comment Share on other sites More sharing options...
UEZ Posted September 11, 2011 Share Posted September 11, 2011 (edited) Yes, splitting up in 2 pieces would reduce the flickering dramatically because why printing static labels continuously? expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> _Main() Func _Main() Local $hGUI, $iLabel, $iTimer, $sReadPrevious, $sText, $iLabel_Text $hGUI = GUICreate("Example not with GDI+", 400, 300) $iLabel = GUICtrlCreateLabel("This is a test of the flicker effect based on the size of the sentence. : ", 10, 10, 380, 280) $iLabel_Text = GUICtrlCreateLabel("AA", 330, 10, 30, 280) ;GUICtrlSetBkColor(-1, 0x000) ;GUICtrlSetColor(-1, 0xFFFFFF) ;GUICtrlSetFont(-1, 20) GUISetState(@SW_SHOW, $hGUI) $iTimer = TimerInit() While 1 $sText = _RandomText(50) If $sText <> $sReadPrevious And TimerDiff($iTimer) > 250 Then $iTimer = TimerInit() $sReadPrevious = $sText GUICtrlSetData($iLabel_Text, $sText) $iTimer = TimerInit() EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>_Main Func _RandomText($iLength = 7) Local $sData = "", $sRandom For $A = 1 To $iLength $sRandom = Random(55, 116, 1) $sData = Chr($sRandom + 6 * ($sRandom > 90) - 7 * ($sRandom < 65)) & Chr($sRandom + 6 * ($sRandom > 90) - 7 * ($sRandom < 65)) Next Return $sData EndFunc ;==>_RandomText Br, UEZ Edited September 11, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
thawee Posted September 11, 2011 Author Share Posted September 11, 2011 (edited) I have split up the static text vs the changing text, and found that it does reduce some of the flicker. Is there any way to update a label with the core element for GuiSetData outside of the main loop? because I have noticed even if its in the main loop even if its not being updated at the moment it still causes a flicker effect. Maybe Making the whole program work with ;Opt("GUIOnEventMode",1) or something? GUICtrlSetData($iLabel_Text, $sText) ; Moved outside the main loop for example purposes. While 1 $sText = _RandomText(50) If $sText <> $sReadPrevious And TimerDiff($iTimer) > 150 Then $iTimer = TimerInit() $sReadPrevious = $sText EndIf Even if i put a control statement to keep from updating the Label continuously, it still flickers as if its being updated every second. As demonstrated here in the code below. expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> _Main() Func _Main() Local $hGUI, $iLabel, $sReadPrevious, $sText,$MenuUpdateCntr ;$iTimer, $hGUI = GUICreate("Example not with GDI+", 400, 300) $iLabel = GUICtrlCreateLabel("", 10, 10, 380, 280) ;GUICtrlSetBkColor(-1, 0x000) ;GUICtrlSetColor(-1, 0xFFFFFF) ;GUICtrlSetFont(-1, 20) GUISetState(@SW_SHOW, $hGUI) $iTimer = TimerInit() While 1 $sText = _RandomText(50) If $MenuUpdateCntr >= 400 Then $iTimer = TimerInit() $sReadPrevious = $sText GUICtrlSetData($iLabel,"This is a test of the flicker effect based on the size of the sentance. : " & $sText) $MenuUpdateCntr = 0 EndIf ;If $sText <> $sReadPrevious And TimerDiff($iTimer) > 150 Then ;EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $MenuUpdateCntr = $MenuUpdateCntr + 1 WEnd EndFunc ;==>_Main Func _RandomText($iLength = 7) Local $sData = "", $sRandom For $A = 1 To $iLength $sRandom = Random(55, 116, 1) $sData = " TEXT TEXT" ;Chr($sRandom + 6 * ($sRandom > 90) - 7 * ($sRandom < 65)) & Chr($sRandom + 6 * ($sRandom > 90) - 7 * ($sRandom < 65)) Next Return $sData EndFunc Is it possible this flickering is a limitation of autoit? Thanks for continuing to help me out I appreciate it. Thawee Edited September 11, 2011 by thawee Link to comment Share on other sites More sharing options...
UEZ Posted September 11, 2011 Share Posted September 11, 2011 Well, I forgotten the $iTimer = TimerInit() in the while loop (updated in my previous post). Beside that I cannot see any flickering in the GUI! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
guinness Posted September 11, 2011 Share Posted September 11, 2011 Neither can I. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
thawee Posted September 12, 2011 Author Share Posted September 12, 2011 Awesome!!! You figured it out! Man I have been banging my head against the wall for a while!! Thanks so much, Thawee Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now