faldo Posted April 17, 2007 Share Posted April 17, 2007 I need my script to run a check of a registry key every 10th seconds while still being able to look for mesages sent from buttons in the GUI. I know that Sleep() don't work well in a GUIGetMsg() since it halts the process from getting messages from controlls. So i came up with a very clumbsy wy of doing this and was wondering if anyone has a better idea of how to do this. This is what i wanted to do: GUICreate("My GUI") $Button = GUICtrlCreateButton ( "Registry value", 10, 30, 100) GUISetState (@SW_SHOW) While 1 $msg = GUIGetMsg() $RegVal = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") If $msg = $Button then MsgBox(0, 'The registry value is now:', $RegVal) Sleep (10000) If $msg = $GUI_EVENT_CLOSE Then ExitLoop WendoÝ÷ Ù8^²W¥û§rب)íéh¢®÷¬*n®,zÜç$x-ëÚç½êò×Ka±ç(Öl¢¥¶Ëa{béh¢(¶×mæ¶´ß©¬*-+"³Z¶'bu«¢+ÙU% ÉÑ ÅÕ½Ðí5äU$ÅÕ½Ðì¤(ÀÌØí ÕÑѽ¸ôU% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½ÐíI¥ÍÑÉäÙ±ÕÅÕ½Ðì°ÄÀ°ÌÀ°ÄÀÀ¤)U%MÑMÑÑ¡M]}M!=¤()¥´ÀÌØí±äôÀ°ÀÌØíIY°ôII ÅÕ½Ðí!-e}1= 1}5 !%9ÀäÈíM=Q]IÀäÈí5¥É½Í½ÐÀäÈí]¥¹½ÝÌÀäÈí ÕÉɹÑYÉÍ¥½¸ÅÕ½Ðì°ÅÕ½ÐíAɽɵ¥±Í¥ÈÅÕ½Ðì¤)]¡¥±Ä(ÀÌØíµÍôU%Ñ5Í ¤((ÀÌØí±äôÀÌØí±ä¬Ä(%ÀÌØí±äôÄÀÀÀÑ¡¸(ÀÌØíIY°ôII ÅÕ½Ðí!-e}1= 1}5 !%9ÀäÈíM=Q]IÀäÈí5¥É½Í½ÐÀäÈí]¥¹½ÝÌÀäÈí ÕÉɹÑYÉÍ¥½¸ÅÕ½Ðì°ÅÕ½ÐíAɽɵ¥±Í¥ÈÅÕ½Ðì¤(ÀÌØí±äôÀ(¹¥((%ÀÌØíµÍôÀÌØí ÕÑѽ¸Ñ¡¸5Í ½à À°ÌäíQ¡É¥ÍÑÉäٱե̹½ÜèÌäì°ÀÌØíIY°¤((%ÀÌØíµÍôÀÌØíU%}Y9Q} 1=MQ¡¸á¥Ñ1½½À)]¹ Instead of the script actually pausing 10 seconds it adds 1 to a delay variable until it reaches aproximatly 10 seconds (don't need it to be exactly 10 anyways) and then checks the registry and resets the delay varible. I'm not prowd of this solution and even though i havn't noticed it, this way may defeat the "automatic CPU idle" function of GUIGetMsg()... is there a better way of doing it? Cheers, Faldo Check out my other scripts: RDP antihammer/blacklist generator | Phemex cryptocurrency exchange API Link to comment Share on other sites More sharing options...
evilertoaster Posted April 17, 2007 Share Posted April 17, 2007 The AdlibEnable() command is what you are looking for. Link to comment Share on other sites More sharing options...
faldo Posted April 18, 2007 Author Share Posted April 18, 2007 Thanx alot, works perfektly Check out my other scripts: RDP antihammer/blacklist generator | Phemex cryptocurrency exchange API Link to comment Share on other sites More sharing options...
therks Posted April 18, 2007 Share Posted April 18, 2007 I don't know how well this would work, and it's not a whole lot different than your last example, but I just wanted to mention the TimerInit and TimerDiff functions. Where you used a variable that you constantly added 1 to and approximated that each 1 would be a millisecond, the timer functions would give you more correct results. You would use them as such (to modify your example): GUICreate("My GUI") $Button = GUICtrlCreateButton ( "Registry value", 10, 30, 100) GUISetState (@SW_SHOW) Dim $RegVal = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") Dim $Timer = TimerInit() While 1 $msg = GUIGetMsg() If TimerDiff($Timer) > 10000 Then $RegVal = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") $Timer = TimerInit() Endif If $msg = $Button then MsgBox(0, 'The registry value is now:', $RegVal) If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Like I said, not much different, but a little more exact, and you may find the functions handy for future use. My AutoIt Stuff | My Github 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