Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Alternate method of getting GUI messages

$
0
0
I am trying to make a way to interrupt an ongoing process to still have access to GUI aspects etc.

Here I am trying to grab GUI messages ASAP with an adlib. The issue is the CPU does spike even though it is doing the same thing as being inside a while 1 loop. Every 1 milisecond it grabs the info and thats it.

Now, the only thing I have come up with is the adlib its self is doing more work than a while 1 loop that just grabs the messages. However that is a guess. The fact it only fires off ever 1 millisecond should offer some CPU protection though because a while loop without any sleeps fires off hundreds of times in 1 millisecond...

[ autoit ]         
#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $GUI = GUICreate("GUI Window", 205, 73, -1, -1) $Button1 = GUICtrlCreateButton("Button1", 8, 8, 187, 57) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $nMsg AdlibRegister('GUIGetMessages', 1) While 1 Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func GUIGetMessages() $nMsg = GUIGetMsg() EndFunc

Can you tell me what you think a good way to make something like this work without wasting CPU is? Preferably a simple elegant method rather than complicated and convoluted.

The idea behind this kind of code was that at a later time in the script I could just check the $nMsg for something and perform an action at any point in my script without breaking anything.

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>