Morthawt Posted December 2, 2012 Share Posted December 2, 2012 (edited) Since the examples section is not really supposed to be for getting help I will post this modification here. I am trying to get my random colour drawer script to work using GUIRegisterMsg instead of using loops, sleeps and _ispressed all the time. The issue is even though there are no blocking loops it is not detecting the mouse up's or any other down's and so it just wants to let you draw endlessly without having any way to stop. Can you have a quick look to see what I am doing wrong? Why won't it stop drawing (creating labels or colouring them) when you release the left mouse button? expandcollapse popupAutoItSetOption('MouseCoordMode', 2) Global $hBox[62][62], $hGUI, $fLeftMouseDown = False, $fRightMouseDown = False, $x, $y, $fColourRandom = True $iTest = 0 ; Set this to 1 to force random and automatic dot placement. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> CreateTheGUI() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd Func CreateTheGUI() $hGUI = GUICreate("", 300, 300, -1, -1) GUISetBkColor('0x000000') GUISetState(@SW_SHOW) GUIRegisterMsg($WM_MOUSEMOVE, "MouseMoveCheck") GUIRegisterMsg($WM_LBUTTONDOWN, "LeftMouseDown") GUIRegisterMsg($WM_LBUTTONUP, "LeftMouseUp") GUIRegisterMsg($WM_RBUTTONDOWN, "RightMouseDown") GUIRegisterMsg($WM_RBUTTONUP, "RightMouseUp") EndFunc ;==>CreateTheGUI Func LeftMouseDown($finput) ConsoleWrite('L-Down ' & Random(1, 1000, 1) & @CRLF) $fLeftMouseDown = True $fColourRandom = True EndFunc ;==>LeftMouseDown Func RightMouseDown($finput) ConsoleWrite('R-Down ' & Random(1, 1000, 1) & @CRLF) $fRightMouseDown = True $fColourRandom = False EndFunc ;==>RightMouseDown Func RightMouseUp($finput) ConsoleWrite('R-Up ' & Random(1, 1000, 1) & @CRLF) $fRightMouseDown = False EndFunc ;==>RightMouseUp Func LeftMouseUp($finput) ConsoleWrite('L-Up ' & Random(1, 1000, 1) & @CRLF) $fLeftMouseDown = False EndFunc ;==>LeftMouseUp Func MouseMoveCheck() $x = Floor(MouseGetPos(0) / 5) $y = Floor(MouseGetPos(1) / 5) Switch $fColourRandom Case True $colour = '0x' & Hex(Random(1, 16581375, 1), 6) Case False $colour = '0x000000' EndSwitch If $x >= 0 And $y >= 0 And $x <= 60 And $y <= 60 And $fLeftMouseDown = True Then If GUICtrlGetHandle($hBox[$x][$y]) = 0 Then $hBox[$x][$y] = GUICtrlCreateLabel("", $x * 5, $y * 5, 5, 5) GUICtrlSetBkColor($hBox[$x][$y], $colour) EndIf EndFunc ;==>MouseMoveCheck Edited December 2, 2012 by Morthawt Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
trancexx Posted December 2, 2012 Share Posted December 2, 2012 At first glance, probably because the message is posted to the new window (label) that you create and not the main window. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Morthawt Posted December 3, 2012 Author Share Posted December 3, 2012 thanks Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
kylomas Posted December 3, 2012 Share Posted December 3, 2012 (edited) Morthawt,Add $fLeftMouseDown = false at the end of MouseMoveCheck()kylomasEdit: releases the mouse but screws up the drawing Edited December 3, 2012 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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