RealisT Posted November 23, 2010 Share Posted November 23, 2010 WINDOWS XP SP3 A test script in Message Mode polls for mouse click events and creates a new label at the coords of the click event. Inexplicably, the code for the Mouse Click event fires constantly, painting the GUI with countless new labels. Why is the mouse event firing without any mouse clicks? - The mouse works fine. Ordinary use in everything else (including AutoIt scripts) confirms that. This is an issue specific to this script. Here is the code. I see no reason why the code in the $GUI_EVENT_PRIMARYDOWN case should be executed without mouse clicks. What is this code missing? I don't want to switch to OnEvent mode. #include <GUIConstants.au3> AutoItSetOption("WinTitleMatchMode", 2) $mainForm = GUICreate("DYNAMIC CONTROL ADD", @DesktopWidth, @DesktopHeight, 0, 0) GUISetBkColor(0xCCAAAA) $mainLabel = GUICtrlCreateLabel("Click Screen", @DesktopWidth/2 - 200, 0, 400, 70, $SS_CENTER) GUICtrlSetFont($mainLabel, 36, 600, 0, "Impact") GUICtrlSetColor($mainLabel, 0x339966) GUICtrlSetBkColor($mainLabel, 0xaaccff) GUISetState () While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN $mouse = MouseGetPos() $newLabel = GUICtrlCreateLabel("", $mouse[0], $mouse[1], 72, 54) GUICtrlSetBkColor($newLabel, 0xFFFFFF) GUISetState () EndSelect Wend Exit Link to comment Share on other sites More sharing options...
whim Posted November 23, 2010 Share Posted November 23, 2010 try replacing ... Case $GUI_EVENT_PRIMARYDOWN by ... Case $msg = $GUI_EVENT_PRIMARYDOWN Link to comment Share on other sites More sharing options...
RealisT Posted November 23, 2010 Author Share Posted November 23, 2010 Doh! Copy & Paste error on my part; pasted over the $msg = . My bad. I look at the same code over & over again and I start to miss things like that. Thank you humbly. 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