TheCrimsonCrusader Posted March 12, 2018 Posted March 12, 2018 Greetings, I know there are several threads regarding text label flickering, but I am just not getting it apparently. In the script I have provided, I want to constantly poll for the IP address and update the text label anytime it changes. I know I can simply change the sleep time in the loop to virtually eliminate that problem, however, later on, I will be adding a clock and other items and those labels won't be precise enough (particularly the clock) by adding additional sleep time. Logically, I was trying to code it where if the IP address isn't the same as it was, then and only then update the label as well, but that wasn't working out for me either, so I was missing something there as well. Any suggestions would be greatly appreciated and thanks in advance! #include <GuiConstants.au3> ;Create GUI GUICreate("Test GUI", 400,300, -1, -1, BitOR($WS_DLGFRAME, $WS_EX_TOPMOST), 0) ;Create label titled "IP Address" GUICtrlCreateLabel("", 2, 185, 193, 38,$SS_ETCHEDFRAME,$WS_EX_DLGMODALFRAME) GUICtrlCreateLabel("IP Address:", 10, 195, 176, 18) GUICtrlSetFont (-1,-1, 800) ;Create label where current IP address will be displayed $IPAddress1 = GUICtrlCreateLabel("", 195, 185, 193, 38,$SS_ETCHEDFRAME,$WS_EX_DLGMODALFRAME) Global $IPAddress2 = GUICtrlCreateLabel(0, 208, 195, 166,18,$ES_READONLY, $WS_EX_TRANSPARENT) ;Show GUI GUISetState(@SW_SHOW) ;Start loop to call set GUI label data by calling IPAddress function while 1 Sleep(10) GUICtrlSetData($IPAddress2, IPAddress()) Wend ;Update IP Address label func IPAddress() Return @IPAddress1 EndFunc
BrewManNH Posted March 12, 2018 Posted March 12, 2018 expandcollapse popup#include <GuiConstants.au3> ;Create GUI GUICreate("Test GUI", 400, 300, -1, -1, BitOR($WS_DLGFRAME, $WS_EX_TOPMOST), 0) ;Create label titled "IP Address" GUICtrlCreateLabel("", 2, 185, 193, 38, $SS_ETCHEDFRAME, $WS_EX_DLGMODALFRAME) GUICtrlCreateLabel("IP Address:", 10, 195, 176, 18) GUICtrlSetFont(-1, -1, 800) ;Create label where current IP address will be displayed $IPAddress1 = GUICtrlCreateLabel("", 195, 185, 193, 38, $SS_ETCHEDFRAME, $WS_EX_DLGMODALFRAME) Global $IPAddress2 = GUICtrlCreateLabel(0, 208, 195, 166, 18, $ES_READONLY, $WS_EX_TRANSPARENT) ;Show GUI GUISetState(@SW_SHOW) Global $IPAddress_Old = "", $IPAddress_New = @IPAddress1 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<< ;Start loop to call set GUI label data by calling IPAddress function While 1 Sleep(10) $IPAddress_New = IPAddress() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<< If $IPAddress_Old <> $IPAddress_New Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetData($IPAddress2, IPAddress()) $IPAddress_Old = $IPAddress_New ; <<<<<<<<<<<<<<<<<<<<<<<<<<<< EndIf ; <<<<<<<<<<<<<<<<<<<<<<<<<<<< WEnd ;Update IP Address label Func IPAddress() Return @IPAddress1 EndFunc ;==>IPAddress This works. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
TheCrimsonCrusader Posted March 12, 2018 Author Posted March 12, 2018 (edited) Thanks, BrewMan! That works (just need to throw different IP change scenarios against it) and what you added there makes complete sense now after seeing it. Kind of like the puzzles in the Myst series. :-) Edited March 12, 2018 by TheCrimsonCrusader
BrewManNH Posted March 12, 2018 Posted March 12, 2018 Learned it long ago, glad I could pay it forward. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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