NELyon Posted April 10, 2008 Share Posted April 10, 2008 I'm having a wee bit o' trouble here. Once upon a midnight dreary whilst I pondered, weak and weary... Ok, enough with the Poe. My GUI Message loop is lagging very badly. When I click a button it takes up to 5 seconds to respond. Code: #Include <GUIConstantsEx.au3> #Include <WindowsConstants.au3> ;#include <MouseSetOnEvent_UDF.au3> #include <EditConstants.au3> Global $nCont = 0, $xColor = 0x000000 $hGUI = GUICreate("ColorSelect_Tool", 220, 110, -1, -1) WinSetOnTop($hGUI, "", 1) $hColor = GUICtrlCreateLabel("", 0, 0, 50, 50) $hSelectColorFromScreen = GUICtrlCreateButton("Select Color from Screen", 70, 0) $hHex = GUICtrlCreateInput("", 1, 70, 100, -1, $ES_READONLY) GUICtrlSetBkColor($hHex, 0xFFFFFF) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hSelectColorFromScreen ;_MouseSetOnEvent(513, "_Addition") Do If PixelGetColor(MouseGetPos(0), MouseGetPos(1)) <> $xColor Then $xColor = PixelGetColor(MouseGetPos(0), MouseGetPos(1)) GUICtrlSetBkColor($hColor, $xColor) EndIf Until $nCont <> 0 ;_MouseSetOnEvent(513) GUICtrlSetData($hHex, "0x" & StringRight(Hex($xColor), 6)) $nCont = 0 Case Else Sleep(200) EndSwitch WEnd Func _Addition() $nCont += 1 EndFunc I commented out the part which requires Mscreator's MouseSetOnEvent UDF, so you can see the problem. When you click the button or the X, it takes up to 5 seconds to respond. Is this just my computer being an Edgar Allen Poe? <<Lol @ The random name dropping Link to comment Share on other sites More sharing options...
GEOSoft Posted April 10, 2008 Share Posted April 10, 2008 take out the sleep(200). there is a delay in the loop anyway. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
NELyon Posted April 10, 2008 Author Share Posted April 10, 2008 Okay. Thanks. Link to comment Share on other sites More sharing options...
Nevin Posted April 10, 2008 Share Posted April 10, 2008 eh, that fix it? You said 5 second delay, that wasn't even half a sec. Link to comment Share on other sites More sharing options...
JustinReno Posted April 10, 2008 Share Posted April 10, 2008 That is a huge difference, even Sleep(100) slows it down considerably. 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